Skip to content

Commit

Permalink
fix: use BlankNode according to RDF/JS spec (#346)
Browse files Browse the repository at this point in the history
Co-authored-by: Tomasz Pluskiewicz <[email protected]>
  • Loading branch information
jeswr and tpluscode authored Mar 27, 2023
1 parent f4887f3 commit f3898fd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.0",
"@babel/register": "^7.16.0",
"@rdfjs/data-model": "^1",
"arrayify-stream": "^1.0.0",
"browserify": "^17.0.0",
"chai": "^4.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/N3Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class N3Parser {
this._inversePredicate = false;
// In N3, blank nodes are scoped to a formula
// (using a dot as separator, as a blank node label cannot start with it)
this._prefixes._ = (this._graph ? `${this._graph.id.substr(2)}.` : '.');
this._prefixes._ = (this._graph ? `${this._graph.value}.` : '.');
// Quantifiers are scoped to a formula
this._quantified = Object.create(this._quantified);
}
Expand Down
17 changes: 17 additions & 0 deletions test/N3Parser-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import rdfDataModel from '@rdfjs/data-model';
import { Parser, termFromId } from '../src/';
import { NamedNode, BlankNode, Quad } from '../src/N3DataFactory';

Expand Down Expand Up @@ -2486,6 +2487,22 @@ describe('Parser', () => {
});
});

describe('A parser instance with external data factory', () => {
it('should parse', () => {
const parser = new Parser({
baseIRI: BASE_IRI,
format: 'n3',
factory: rdfDataModel,
});
const quads = parser.parse(`
@prefix : <http://example.com/> .
{ :weather a :Raining } => { :weather a :Cloudy } .
`);

quads.length.should.be.gt(0);
});
});

describe('IRI resolution', () => {
describe('RFC3986 normal examples', () => {
itShouldResolve('http://a/bb/ccc/d;p?q', 'g:h', 'g:h');
Expand Down

0 comments on commit f3898fd

Please sign in to comment.