Skip to content

Commit 2409091

Browse files
committed
Remove support for application/nquads alias.
1 parent 20fa0cf commit 2409091

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
usage.
1616
- The internal digest algorithm can be changed.
1717

18+
### Removed
19+
- **BREAKING**: Remove `application/nquads` alias for `application/n-quads`.
20+
1821
## 8.3.2 - 2023-12-06
1922

2023
### Fixed

lib/jsonld.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,7 @@ jsonld.normalize = jsonld.canonize = async function(input, options) {
579579
}, options.canonizeOptions || null);
580580

581581
if('inputFormat' in options) {
582-
if(options.inputFormat !== 'application/n-quads' &&
583-
options.inputFormat !== 'application/nquads') {
582+
if(options.inputFormat !== 'application/n-quads') {
584583
throw new JsonLdError(
585584
'Unknown canonicalization input format.',
586585
'jsonld.CanonizeError');
@@ -700,8 +699,7 @@ jsonld.toRDF = async function(input, options) {
700699
// output RDF dataset
701700
const dataset = _toRDF(expanded, options);
702701
if(options.format) {
703-
if(options.format === 'application/n-quads' ||
704-
options.format === 'application/nquads') {
702+
if(options.format === 'application/n-quads') {
705703
return NQuads.serialize(dataset);
706704
}
707705
throw new JsonLdError(
@@ -1007,7 +1005,6 @@ jsonld.unregisterRDFParser = function(contentType) {
10071005

10081006
// register the N-Quads RDF parser
10091007
jsonld.registerRDFParser('application/n-quads', NQuads.parse);
1010-
jsonld.registerRDFParser('application/nquads', NQuads.parse);
10111008

10121009
/* URL API */
10131010
jsonld.url = require('./url');

tests/misc.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,18 @@ describe('other toRDF tests', () => {
143143
});
144144
});
145145

146-
it('should handle deprecated N-Quads format', done => {
146+
it('should fail for deprecated N-Quads format', done => {
147147
const doc = {
148148
"@id": "https://example.com/",
149149
"https://example.com/test": "test"
150150
};
151151
const p = jsonld.toRDF(doc, {format: 'application/nquads'});
152152
assert(p instanceof Promise);
153-
p.catch(e => {
154-
assert.ifError(e);
155-
}).then(output => {
156-
assert.equal(
157-
output,
158-
'<https://example.com/> <https://example.com/test> "test" .\n');
153+
p.then(() => {
154+
assert.fail();
155+
}).catch(e => {
156+
assert(e);
157+
assert.equal(e.name, 'jsonld.UnknownFormat');
159158
done();
160159
});
161160
});
@@ -232,21 +231,15 @@ describe('other fromRDF tests', () => {
232231
});
233232
});
234233

235-
it('should handle deprecated N-Quads format', done => {
234+
it('should fail for deprecated N-Quads format', done => {
236235
const nq = '<https://example.com/> <https://example.com/test> "test" .\n';
237236
const p = jsonld.fromRDF(nq, {format: 'application/nquads'});
238237
assert(p instanceof Promise);
239-
p.catch(e => {
240-
assert.ifError(e);
241-
}).then(output => {
242-
assert.deepEqual(
243-
output,
244-
[{
245-
"@id": "https://example.com/",
246-
"https://example.com/test": [{
247-
"@value": "test"
248-
}]
249-
}]);
238+
p.then(() => {
239+
assert.fail();
240+
}).catch(e => {
241+
assert(e);
242+
assert.equal(e.name, 'jsonld.UnknownFormat');
250243
done();
251244
});
252245
});

0 commit comments

Comments
 (0)