identifier-js 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -3
- package/package.json +1 -1
- package/tests/to-absolute.test.js +16 -0
- package/tests/validation-ip-port.test.js +32 -0
package/index.js
CHANGED
|
@@ -285,8 +285,7 @@ module.exports = {
|
|
|
285
285
|
parseIriReference: (string) => parse(string, 'IRI_reference'),
|
|
286
286
|
parseAbsoluteIri: (string) => parse(string, 'absolute_IRI'),
|
|
287
287
|
resolveReference,
|
|
288
|
-
normalizeReference: (string) => string, // not done yet
|
|
289
|
-
toAbsoluteReference: (string) => resolveReference('', string),
|
|
290
288
|
toRelativeReference,
|
|
289
|
+
toAbsoluteReference: (string) => resolveReference('', string),
|
|
290
|
+
normalizeReference: (string) => string, // not done yet
|
|
291
291
|
};
|
|
292
|
-
|
package/package.json
CHANGED
|
@@ -6,6 +6,22 @@ describe('toAbsoluteReference', () => {
|
|
|
6
6
|
expect(id.toAbsoluteReference('http://examplé.org/rosé#dasd')).to.equal('http://examplé.org/rosé');
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
+
test('Base with empty path', () => {
|
|
10
|
+
expect(id.toAbsoluteReference('http://examplé.org')).to.equal('http://examplé.org');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('Base witout authority', () => {
|
|
14
|
+
expect(id.toAbsoluteReference('http:/foo?bar#baz')).to.equal('http:/foo?bar');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('Base witout authority and empty path', () => {
|
|
18
|
+
expect(id.toAbsoluteReference('http:?bar#baz')).to.equal('http:?bar');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('Base witout authority or query and empty path', () => {
|
|
22
|
+
expect(id.toAbsoluteReference('http:#baz')).to.equal('http:');
|
|
23
|
+
});
|
|
24
|
+
|
|
9
25
|
test('Scheme is required', () => {
|
|
10
26
|
expect(() => id.toAbsoluteReference('//example.com/foo?bar#baz')).to.throw(Error, 'Invalid IRI: //example.com/foo?bar#baz');
|
|
11
27
|
});
|
|
@@ -101,6 +101,14 @@ describe('isUri – IPv6 host validation', () => {
|
|
|
101
101
|
test('Invalid IPv6 – empty address literal', () => {
|
|
102
102
|
expect(() => id.isUri('https://[]')).to.throw(Error, 'Invalid URI: https://[]');
|
|
103
103
|
});
|
|
104
|
+
|
|
105
|
+
test('Invalid IPv6 – address literal with missing opening bracket', () => {
|
|
106
|
+
expect(() => id.isUri('https://::1]')).to.throw(Error, 'Invalid URI: https://::1]');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('Invalid IPv6 – address literal with missing closing bracket', () => {
|
|
110
|
+
expect(() => id.isUri('https://[::1')).to.throw(Error, 'Invalid URI: https://[::1');
|
|
111
|
+
});
|
|
104
112
|
});
|
|
105
113
|
|
|
106
114
|
describe('isIri – IPv6 host validation', () => {
|
|
@@ -183,6 +191,14 @@ describe('isIri – IPv6 host validation', () => {
|
|
|
183
191
|
test('Invalid IPv6 – empty address literal', () => {
|
|
184
192
|
expect(() => id.isIri('https://[]')).to.throw(Error, 'Invalid IRI: https://[]');
|
|
185
193
|
});
|
|
194
|
+
|
|
195
|
+
test('Invalid IPv6 – address literal with missing opening bracket', () => {
|
|
196
|
+
expect(() => id.isIri('https://::1]')).to.throw(Error, 'Invalid IRI: https://::1]');
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('Invalid IPv6 – address literal with missing closing bracket', () => {
|
|
200
|
+
expect(() => id.isIri('https://[::1')).to.throw(Error, 'Invalid IRI: https://[::1');
|
|
201
|
+
});
|
|
186
202
|
});
|
|
187
203
|
|
|
188
204
|
describe('isUri – port validation', () => {
|
|
@@ -206,6 +222,14 @@ describe('isUri – port validation', () => {
|
|
|
206
222
|
expect(() => id.isUri('https://example.com: /')).to.throw(Error, 'Invalid URI: https://example.com: /');
|
|
207
223
|
});
|
|
208
224
|
|
|
225
|
+
test('Invalid "space" before port', () => {
|
|
226
|
+
expect(() => id.isUri('https://example.com: 80/')).to.throw(Error, 'Invalid URI: https://example.com: 80/');
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
test('Invalid "space" after port', () => {
|
|
230
|
+
expect(() => id.isUri('https://example.com:80 /')).to.throw(Error, 'Invalid URI: https://example.com:80 /');
|
|
231
|
+
});
|
|
232
|
+
|
|
209
233
|
test('Invalid port char', () => {
|
|
210
234
|
expect(() => id.isUri('https://example.com:ff')).to.throw(Error, 'Invalid URI: https://example.com:ff');
|
|
211
235
|
});
|
|
@@ -236,6 +260,14 @@ describe('isIri – port validation', () => {
|
|
|
236
260
|
expect(() => id.isIri('https://example.com: /')).to.throw(Error, 'Invalid IRI: https://example.com: /');
|
|
237
261
|
});
|
|
238
262
|
|
|
263
|
+
test('Invalid "space" before port', () => {
|
|
264
|
+
expect(() => id.isIri('https://example.com: 80/')).to.throw(Error, 'Invalid IRI: https://example.com: 80/');
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test('Invalid "space" after port', () => {
|
|
268
|
+
expect(() => id.isIri('https://example.com:80 /')).to.throw(Error, 'Invalid IRI: https://example.com:80 /');
|
|
269
|
+
});
|
|
270
|
+
|
|
239
271
|
test('Invalid port char', () => {
|
|
240
272
|
expect(() => id.isIri('https://example.com:ff')).to.throw(Error, 'Invalid IRI: https://example.com:ff');
|
|
241
273
|
});
|