diff --git a/src/N3Writer.js b/src/N3Writer.js index 243a088b..6eb16a33 100644 --- a/src/N3Writer.js +++ b/src/N3Writer.js @@ -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); diff --git a/test/N3StreamWriter-test.js b/test/N3StreamWriter-test.js index 4b8d35b9..0e02629b 100644 --- a/test/N3StreamWriter-test.js +++ b/test/N3StreamWriter-test.js @@ -41,7 +41,7 @@ describe('StreamWriter', () => { '@prefix c: .\n\n' + 'a:bc b:ef a:bhi.\n' + ' .\n' + - ' b:a3.\n'), + 'a:3a b:3a b:a3.\n'), ); it('should take over prefixes from the input stream', done => { diff --git a/test/N3Writer-test.js b/test/N3Writer-test.js index c44ff280..78e17bbc 100644 --- a/test/N3Writer-test.js +++ b/test/N3Writer-test.js @@ -271,7 +271,7 @@ describe('Writer', () => { '@prefix c: .\n\n' + 'a:bc b:ef a:bhi.\n' + ' .\n' + - ' b:a3.\n'), + 'a:3a b:3a b:a3.\n'), ); it( @@ -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(' << >> .\n'); }); + }); });