@dench.com/cli 3.11.10-staging.519 → 3.11.11-staging.522
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/openUrl.ts +20 -2
- package/package.json +1 -1
package/openUrl.ts
CHANGED
|
@@ -51,7 +51,11 @@ function openerCommand(url: string, currentPlatform: NodeJS.Platform) {
|
|
|
51
51
|
return { command: "open", args: [url] };
|
|
52
52
|
}
|
|
53
53
|
if (currentPlatform === "win32") {
|
|
54
|
-
|
|
54
|
+
// Invoke the URL handler directly; cmd interprets metacharacters in URLs.
|
|
55
|
+
return {
|
|
56
|
+
command: "rundll32.exe",
|
|
57
|
+
args: ["url.dll,FileProtocolHandler", url],
|
|
58
|
+
};
|
|
55
59
|
}
|
|
56
60
|
return { command: "xdg-open", args: [url] };
|
|
57
61
|
}
|
|
@@ -63,8 +67,22 @@ export async function openUrl(
|
|
|
63
67
|
const reason = disabledReason(options);
|
|
64
68
|
if (reason) return { status: "skipped", reason };
|
|
65
69
|
|
|
70
|
+
let target: URL;
|
|
71
|
+
try {
|
|
72
|
+
target = new URL(url);
|
|
73
|
+
} catch {
|
|
74
|
+
return { status: "skipped", reason: "invalid-url" };
|
|
75
|
+
}
|
|
76
|
+
if (
|
|
77
|
+
(target.protocol !== "https:" && target.protocol !== "http:") ||
|
|
78
|
+
target.username ||
|
|
79
|
+
target.password
|
|
80
|
+
) {
|
|
81
|
+
return { status: "skipped", reason: "unsafe-url" };
|
|
82
|
+
}
|
|
83
|
+
|
|
66
84
|
const { command, args } = openerCommand(
|
|
67
|
-
|
|
85
|
+
target.href,
|
|
68
86
|
options.platform ?? nodePlatform(),
|
|
69
87
|
);
|
|
70
88
|
const spawn = options.spawn ?? (nodeSpawn as SpawnLike);
|