Skip to content

Commit

Permalink
Fix crash on relative base tag values
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Mar 28, 2020
1 parent 730201c commit e564188
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Util {
if (fragmentIndex >= 0) {
href = href.substr(0, fragmentIndex);
}
return this.dataFactory.namedNode(href);
return this.dataFactory.namedNode(resolve(href, this.baseIRI.value));
}

/**
Expand Down
6 changes: 6 additions & 0 deletions test/Util-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,12 @@ describe('Util', () => {
return expect(util.getBaseIRI('http://base.org/#hash'))
.toEqualRdfTerm(namedNode('http://base.org/'));
});

it('should return a relative baseIRI', async () => {
util.baseIRI = namedNode('http://example.org/');
return expect(util.getBaseIRI('abc'))
.toEqualRdfTerm(namedNode('http://example.org/abc'));
});
});
});

Expand Down

0 comments on commit e564188

Please sign in to comment.