diff --git a/CHANGELOG.md b/CHANGELOG.md index 47b8b82f..5992e9a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix safe mode for `@graph` use cases. - Check all elements of graph property with array. - Fix test `pr41` of protected redefinition of equivalent id terms. +- Fix relative IRI parsing. ## 8.2.0 - 2023-05-19 diff --git a/lib/url.js b/lib/url.js index 69c09b47..7e597791 100644 --- a/lib/url.js +++ b/lib/url.js @@ -28,7 +28,7 @@ api.parsers = { 'hostname', 'port', 'path', 'directory', 'file', 'query', 'fragment' ], /* eslint-disable-next-line max-len */ - regex: /^(([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/ + regex: /^(([a-zA-Z][a-zA-Z0-9+-.]*):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?(?:(((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/ } }; api.parse = (str, parser) => { @@ -109,8 +109,6 @@ api.prependBase = (base, iri) => { path = path.substr(0, path.lastIndexOf('/') + 1); if((path.length > 0 || base.authority) && path.substr(-1) !== '/') { path += '/'; - } else if (rel.protocol) { - path += rel.protocol; } path += rel.path; diff --git a/tests/misc.js b/tests/misc.js index 91cc931b..d43d5817 100644 --- a/tests/misc.js +++ b/tests/misc.js @@ -1491,7 +1491,6 @@ _:b0 "v" . testSafe: true }); }); - }); describe('values', () => {