diff --git a/lib/util/identifier.js b/lib/util/identifier.js index b69a3c80..25979815 100644 --- a/lib/util/identifier.js +++ b/lib/util/identifier.js @@ -12,9 +12,7 @@ const EMPTY = ""; * @returns {[string, string, string]|null} parsed identifier */ function parseIdentifier(identifier) { - const match = /^(#?(?:[/\\]#[^/\\?]|[^?#])*)(\?[^#]*)?(#.*)?$/.exec( - identifier - ); + const match = /^(#?[^?#]*)(\?[^#]*)?(#.*)?$/.exec(identifier); if (!match) return null; diff --git a/test/identifier.js b/test/identifier.js index 1bab1ca0..214d7bb1 100644 --- a/test/identifier.js +++ b/test/identifier.js @@ -37,19 +37,19 @@ describe("parse identifier. edge cases", () => { }, { input: "path/#repo#hash", - expect: ["path/#repo", "", "#hash"] + expect: ["path/", "", "#repo#hash"] }, { input: "path/#r#hash", - expect: ["path/#r", "", "#hash"] + expect: ["path/", "", "#r#hash"] }, { input: "path/#repo/#repo2#hash", - expect: ["path/#repo/#repo2", "", "#hash"] + expect: ["path/", "", "#repo/#repo2#hash"] }, { input: "path/#r/#r#hash", - expect: ["path/#r/#r", "", "#hash"] + expect: ["path/", "", "#r/#r#hash"] }, { input: "path/#/not/a/hash?not-a-query", @@ -77,11 +77,11 @@ describe("parse identifier. Windows-like paths", () => { }, { input: "path\\#repo#hash", - expect: ["path\\#repo", "", "#hash"] + expect: ["path\\", "", "#repo#hash"] }, { input: "path\\#r#hash", - expect: ["path\\#r", "", "#hash"] + expect: ["path\\", "", "#r#hash"] }, { input: "path\\#/not/a/hash?not-a-query",