Skip to content

Commit

Permalink
Fixes relative IRI resolution when there is no authority
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpt committed Oct 18, 2024
1 parent d57d747 commit bfbbef7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Changed

- Fixes relativize on hierarchical paths without authority and starting slash Thomas Tanon 31 minutes ago
- Fixes relativize on hierarchical paths without authority and starting slash.

## [0.2.5] - 2024-10-03

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,8 @@ impl<'a, O: OutputBuffer, const UNCHECKED: bool> IriParser<'a, O, UNCHECKED> {
self.output_positions.authority_end = base.positions.authority_end;
self.output_positions.path_end = base.positions.path_end;
self.remove_last_segment();
if self.output.len() > base.positions.scheme_end {
if self.output.len() > base.positions.scheme_end || base.path().starts_with('/')
{
// We have some path or authority, we keep a base '/'
self.output.push('/');
}
Expand Down
2 changes: 2 additions & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ fn test_relativize_iri() {
("urn:is/bn:foo", "urn:", "is/bn:foo"),
("urn:.", "urn:", "."),
("t:e/e/p", "t:e/s", "t:e/e/p"),
("htt:/foo/gp", "htt:/foo/", "gp"),
("htt:/gp", "htt:/", "gp"),
];

for (original, base, output) in examples {
Expand Down

0 comments on commit bfbbef7

Please sign in to comment.