workers-sdk
workers-sdk copied to clipboard
🐛 BUG: CLI options --var and --define remove all colons from values
What version of Wrangler are you using?
2.0.29
What operating system are you using?
Mac
Describe the Bug
If you pass a value with a colon in --var (or --define based on the code), the colon will be removed when used.
Relevant PR: #1730 Problematic code: https://github.com/cloudflare/wrangler2/blob/893830aaea4391f4b25841132c3cb0ab5d967c60/packages/wrangler/src/index.tsx#L582
const cliVars =
args.var?.reduce<Record<string, string>>((collectVars, v) => {
const [key, ...value] = v.split(":");
collectVars[key] = value.join("");
return collectVars;
}, {}) || {};
Calling .split(":") removes all of the colons from the value. For example, a URL will turn from this https://www.cloudflare.com, into https//www.cloudflare.com thus making it not a URL anymore :-(