diff --git a/src/index.spec.ts b/src/index.spec.ts index cef557f..f842413 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -15,14 +15,14 @@ describe("path-to-regexp", () => { it("should throw on unbalanced group", () => { expect(() => parse("/{:foo,")).toThrow( new TypeError( - "Unexpected END at 7, expected }: https://git.new/pathToRegexpError", + "Unexpected END at 7, expected }: visit https://git.new/pathToRegexpError for more information.", ), ); }); it("should throw on nested unbalanced group", () => { expect(() => parse("/{:foo/{x,y}")).toThrow( new TypeError( - "Unexpected END at 12, expected }: https://git.new/pathToRegexpError", + "Unexpected END at 12, expected }: visit https://git.new/pathToRegexpError for more information.", ), ); }); @@ -30,7 +30,7 @@ describe("path-to-regexp", () => { it("should throw on missing param name", () => { expect(() => parse("/:/")).toThrow( new TypeError( - "Missing parameter name at 2: https://git.new/pathToRegexpError", + "Missing parameter name at 2: visit https://git.new/pathToRegexpError for more information.", ), ); }); @@ -38,7 +38,7 @@ describe("path-to-regexp", () => { it("should throw on missing wildcard name", () => { expect(() => parse("/*/")).toThrow( new TypeError( - "Missing parameter name at 2: https://git.new/pathToRegexpError", + "Missing parameter name at 2: visit https://git.new/pathToRegexpError for more information.", ), ); }); @@ -46,7 +46,7 @@ describe("path-to-regexp", () => { it("should throw on unterminated quote", () => { expect(() => parse('/:"foo')).toThrow( new TypeError( - "Unterminated quote at 2: https://git.new/pathToRegexpError", + "Unterminated quote at 2: visit https://git.new/pathToRegexpError for more information.", ), ); }); diff --git a/src/index.ts b/src/index.ts index c178797..919c3ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -145,12 +145,16 @@ function* lexer(str: string): Generator { } if (pos) { - throw new TypeError(`Unterminated quote at ${pos}: ${DEBUG_URL}`); + throw new TypeError( + `Unterminated quote at ${pos}: visit ${DEBUG_URL} for more information.`, + ); } } if (!value) { - throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`); + throw new TypeError( + `Missing parameter name at ${i}: visit ${DEBUG_URL} for more information.`, + ); } return value; @@ -203,7 +207,7 @@ class Iter { if (value !== undefined) return value; const { type: nextType, index } = this.peek(); throw new TypeError( - `Unexpected ${nextType} at ${index}, expected ${type}: ${DEBUG_URL}`, + `Unexpected ${nextType} at ${index}, expected ${type}: visit ${DEBUG_URL} for more information.`, ); } @@ -575,7 +579,9 @@ function toRegExp(tokens: Flattened[], delimiter: string, keys: Keys) { if (token.type === "param" || token.type === "wildcard") { if (!isSafeSegmentParam && !backtrack) { - throw new TypeError(`Missing text after "${token.name}": ${DEBUG_URL}`); + throw new TypeError( + `Missing text after "${token.name}": visit ${DEBUG_URL} for more information.`, + ); } if (token.type === "param") {