Skip to content

Commit 93f4c8a

Browse files
authored
Fix shell quoting on windows machines to avoid upload errors (#976)
1 parent b455640 commit 93f4c8a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.changeset/thick-oranges-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
fix: shell quoting on windows machines to avoid upload errors for routes with `[...path]` segments

packages/cloudflare/src/cli/commands/helpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ export async function getEnvFromPlatformProxy(options: GetPlatformProxyOptions,
8383
* @returns escaped arg
8484
*/
8585
export function quoteShellMeta(arg: string) {
86+
if (process.platform === "win32") {
87+
if (arg.length === 0) {
88+
return '""';
89+
}
90+
const needsEscaping = /[&|<>^()%!"]/;
91+
const needsQuotes = /\s/.test(arg) || needsEscaping.test(arg);
92+
let escaped = arg.replace(/"/g, '""');
93+
if (/[&|<>^()%!]/.test(arg)) {
94+
escaped = escaped.replace(/[&|<>^()%!]/g, "^$&");
95+
}
96+
return needsQuotes ? `"${escaped}"` : escaped;
97+
}
8698
if (/["\s]/.test(arg) && !/'/.test(arg)) {
8799
return `'${arg.replace(/(['\\])/g, "\\$1")}'`;
88100
}

0 commit comments

Comments
 (0)