Skip to content

Commit

Permalink
Fix relative IRI parsing.
Browse files Browse the repository at this point in the history
- Undo previous "protocol" fix for `123:abc` style relative IRIs.
- Update IRI parser to be more strict for RFC3986 URI schemes.
  • Loading branch information
davidlehn committed Aug 31, 2023
1 parent 52c6e8d commit cc46c34
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion tests/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,6 @@ _:b0 <ex:p> "v" .
testSafe: true
});
});

});

describe('values', () => {
Expand Down

0 comments on commit cc46c34

Please sign in to comment.