Marketing skills for Claude Code and AI agents. CRO, copywriting, SEO, analytics, and growth engineering.
JavaScript agent-skillsai-agentsai-seoclaudeclaude-codeclaude-code-pluginclaude-skillscodexcontent-marketingconversion-rate-optimizationcopywritingcursoremail-marketinggenerative-engine-optimizationgrowth-marketingmarketingmarketing-automationsaas-marketingseoskill-md
fix(email): preserve colons in template and event values
Rudy Celekli86634cf8e8bb
diff --git a/tests/email-colon-values.test.cjs b/tests/email-colon-values.test.cjsnew file mode 100644index 0000000..be58569--- /dev/null+++ b/tests/email-colon-values.test.cjs@@ -0,0 +1,37 @@+const { test } = require('node:test')+const assert = require('node:assert/strict')+const { spawnSync } = require('node:child_process')+const path = require('node:path')+function run(vendor, args, fetch = true) {+ const cli = path.resolve(__dirname, `../tools/clis/${vendor}.js`)+ const source = `global.fetch = async (url, options) => {+ if (!${fetch}) throw new Error('Unexpected network request');+ return { status: 200, text: async () => JSON.stringify({ url, method: options.method, body: options.body ? JSON.parse(options.body) : null }) };+ }; process.argv = ['node', ${JSON.stringify(cli)}, ...${JSON.stringify(args)}]; require(${JSON.stringify(cli)});`+ return spawnSync(process.execPath, ['-e', source], { encoding: 'utf8', timeout: 5000, env: {+ ...process.env, REWARDFUL_API_KEY: 'fake-key', RESEND_API_KEY: 'fake-key', POSTMARK_API_KEY: 'fake-key', BEEHIIV_API_KEY: 'fake-key', KLAVIYO_API_KEY: 'fake-key',+ } })+}+function output(result) { assert.equal(result.status, 0, result.stderr); return JSON.parse(result.stdout) }++const values = { reset_url: 'https://example.com/reset:443/token?next=https://example.com', at: '10:30:00', name: 'Zoë' }+test('Postmark template model keeps URL and timestamp values after the first colon', () => {+ const result = output(run('postmark', ['email', 'send-template', '--from', '[email protected]', '--to', '[email protected]', '--template', 'welcome', '--model', Object.entries(values).map(([k,v]) => `${k}:${v}`).join(',')]))+ assert.deepEqual(result.body.TemplateModel, values)+ assert.equal(result.body.TemplateAlias, 'welcome')+})+test('Klaviyo custom event properties keep colon-containing values', () => {+ const result = output(run('klaviyo', ['events', 'create', '--metric', 'Reset Password', '--email', '[email protected]', '--property', Object.entries(values).map(([k,v]) => `${k}:${v}`).join(',')]))+ assert.deepEqual(result.body.data.attributes.properties, values)+})+test('ordinary key/value pairs and malformed entries retain existing behavior', () => {+ const result = output(run('postmark', ['email', 'send-template', '--from', '[email protected]', '--to', '[email protected]', '--template', '123', '--model', 'name:Jane,missing,:emptykey,empty:']))+ assert.deepEqual(result.body.TemplateModel, { name: 'Jane' })+ assert.equal(result.body.TemplateId, 123)+})+test('template model dry run preserves URL payload without fetching or credentials', () => {+ const result = output(run('postmark', ['email', 'send-template', '--from', '[email protected]', '--to', '[email protected]', '--template', 'welcome', '--model', 'reset_url:https://example.com/reset', '--dry-run'], false))+ assert.equal(result.body.TemplateModel.reset_url, 'https://example.com/reset')+ assert.equal(result.headers['X-Postmark-Server-Token'], '***')+ assert.equal(JSON.stringify(result).includes('fake-key'), false)+})diff --git a/tools/clis/klaviyo.js b/tools/clis/klaviyo.jsindex d74966f..45b26fa 100755--- a/tools/clis/klaviyo.js+++ b/tools/clis/klaviyo.js@@ -187,7 +187,8 @@ async function main() {if (args.property) {const pairs = args.property.split(',')for (const pair of pairs) {- const [k, v] = pair.split(':')+ const [k, ...valueParts] = pair.split(':')+ const v = valueParts.join(':')if (k && v) properties[k] = v}}diff --git a/tools/clis/postmark.js b/tools/clis/postmark.jsindex e66ca08..5f8c0c0 100755--- a/tools/clis/postmark.js+++ b/tools/clis/postmark.js@@ -115,7 +115,8 @@ async function main() {if (args.model) {const pairs = args.model.split(',')for (const pair of pairs) {- const [k, v] = pair.split(':')+ const [k, ...valueParts] = pair.split(':')+ const v = valueParts.join(':')if (k && v) body.TemplateModel[k] = v}}