identifier-js 0.0.6 → 0.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "identifier-js",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "A RFC3986 / RFC3987 compliant fast parser/validator/resolver/composer for NodeJS and browser.",
5
5
  "keywords": [
6
6
  "IRI",
@@ -0,0 +1,21 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import id from '../index.js';
3
+ // not yet done
4
+ const resolveTests = [
5
+ ['', 'hTTp://example.com/b/c/d/e', 'http://example.com/b/c/d/e'], // scheme to lowercase
6
+ ['', 'http://eXaMpLe.com/b/c/d/e', 'http://example.com/b/c/d/e'], // authority to lowercase
7
+ ['', 'http://example.com/b%2Ec/d/e', 'http://example.com/b.c/d/e'], // Unnecessary encoding segment
8
+ ['', 'http://example.com/b%2Fc/d/e', 'http://example.com/b%2Fc/d/e'], // Necessary encoding segment
9
+ ['', 'http://example.com/b%2fc/d/e', 'http://example.com/b%2Fc/d/e'], // Case normalization of encoding segment
10
+ ['', 'http://example.com/b?c%2Fd%3Fe', 'http://example.com/b?c/d?e'], // Unnecessary encoding query
11
+ ['#c%2Fd%3Fe', 'http://example.com/b', 'http://example.com/b#c/d?e'], // Unnecessary encoding fragment
12
+ ];
13
+
14
+ describe('resolveReference', () => {
15
+ resolveTests.forEach(([reference, base, expected]) => {
16
+ test(`resolveReference('${reference}', '${base}') === '${expected}'`, () => {
17
+ const subject = id.normalizeReference(reference, base);
18
+ expect(subject).to.equal(expected);
19
+ });
20
+ });
21
+ });
@@ -44,6 +44,7 @@ const refs = {
44
44
  "g?y/../x" : "http://a/b/c/g?y/../x",
45
45
  "g#s/./x" : "http://a/b/c/g#s/./x",
46
46
  "g#s/../x" : "http://a/b/c/g#s/../x",
47
+ "http:g" : "http:g",
47
48
  }
48
49
 
49
50
  describe('resolveReference', () => {
@@ -4,13 +4,6 @@ import id from '../index.js';
4
4
  const resolveTests = [
5
5
  ['urn:some:ip:prop', 'urn:some:ip:prop', 'urn:some:ip:prop'],
6
6
  ['urn:some:ip:prop', 'urn:some:other:prop', 'urn:some:ip:prop'],
7
- ['', 'hTTp://example.com/b/c/d/e', 'http://example.com/b/c/d/e'], // scheme to lowercase
8
- ['', 'http://eXaMpLe.com/b/c/d/e', 'http://example.com/b/c/d/e'], // authority to lowercase
9
- ['', 'http://example.com/b%2Ec/d/e', 'http://example.com/b.c/d/e'], // Unnecessary encoding segment
10
- ['', 'http://example.com/b%2Fc/d/e', 'http://example.com/b%2Fc/d/e'], // Necessary encoding segment
11
- ['', 'http://example.com/b%2fc/d/e', 'http://example.com/b%2Fc/d/e'], // Case normalization of encoding segment
12
- ['', 'http://example.com/b?c%2Fd%3Fe', 'http://example.com/b?c/d?e'], // Unnecessary encoding query
13
- ['#c%2Fd%3Fe', 'http://example.com/b', 'http://example.com/b#c/d?e'], // Unnecessary encoding fragment
14
7
  ];
15
8
 
16
9
  describe('resolveReference', () => {