Skip to content

Commit

Permalink
feat: allow digits in the local part of prefixed names. (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
mightymax authored Nov 8, 2024
1 parent da8b2d0 commit 3b6ff6b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/N3Writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export default class N3Writer {
}
IRIlist = escapeRegex(IRIlist, /[\]\/\(\)\*\+\?\.\\\$]/g, '\\$&');
this._prefixRegex = new RegExp(`^(?:${prefixList})[^\/]*$|` +
`^(${IRIlist})([_a-zA-Z][\\-_a-zA-Z0-9]*)$`);
`^(${IRIlist})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`);
}
// End a prefix block with a newline
this._write(hasPrefixes ? '\n' : '', done);
Expand Down
2 changes: 1 addition & 1 deletion test/N3StreamWriter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('StreamWriter', () => {
'@prefix c: <http://a.org/b>.\n\n' +
'a:bc b:ef a:bhi.\n' +
'<http://a.org/bc/de> <http://a.org/b#e#f> <http://a.org/b#x/t>.\n' +
'<http://a.org/3a> <http://a.org/b#3a> b:a3.\n'),
'a:3a b:3a b:a3.\n'),
);

it('should take over prefixes from the input stream', done => {
Expand Down
3 changes: 2 additions & 1 deletion test/N3Writer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ describe('Writer', () => {
'@prefix c: <http://a.org/b>.\n\n' +
'a:bc b:ef a:bhi.\n' +
'<http://a.org/bc/de> <http://a.org/b#e#f> <http://a.org/b#x/t>.\n' +
'<http://a.org/3a> <http://a.org/b#3a> b:a3.\n'),
'a:3a b:3a b:a3.\n'),
);

it(
Expand Down Expand Up @@ -902,6 +902,7 @@ describe('Writer', () => {
writer.quadToString(new NamedNode('a'), new NamedNode('b'), new Quad(new NamedNode('a'), new NamedNode('b'), new NamedNode('c'), new NamedNode('g'))),
).toBe('<a> <b> <<<a> <b> <c> <g>>> .\n');
});

});
});

Expand Down

0 comments on commit 3b6ff6b

Please sign in to comment.