fix(javascript): recognize digits in artifact URI schemes (#1045)

This commit is contained in:
Alex
2026-10-08 12:28:34 +08:00
committed by GitHub
parent 6b55de017b
commit 03424ae91e
4 changed files with 47 additions and 1 deletions
+5
View File
@@ -12,6 +12,11 @@ describe("artifact path syntax", () => {
expect(hasScheme("https://example.test/app.js")).toBe(true);
expect(hasScheme("file:///app.js")).toBe(true);
expect(hasScheme("node:fs")).toBe(true);
expect(hasScheme("web3:app.js")).toBe(true);
expect(hasScheme("h323:user@example.test")).toBe(true);
expect(hasScheme("x1+custom.v2-test:asset")).toBe(true);
expect(hasScheme("3web:app.js")).toBe(false);
expect(hasScheme("./web3:app.js")).toBe(false);
expect(hasScheme("./relative.js")).toBe(false);
expect(hasScheme("/absolute.js")).toBe(false);
expect(hasScheme("app.js")).toBe(false);
+1 -1
View File
@@ -17,7 +17,7 @@
/** Whether a reference carries a URI scheme (`https:`, `file:`, …). */
export const hasScheme = (value: string): boolean =>
/^[A-Za-z][A-Za-z+.-]*:/u.test(value);
/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(value);
/** Whether a reference is scheme-qualified or protocol-relative. */
export const looksExternal = (value: string): boolean =>