Skip to content

Instantly share code, notes, and snippets.

@cantremember
Created May 10, 2021 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cantremember/759609b4bd8e134c02d2fb6118252ef7 to your computer and use it in GitHub Desktop.
Save cantremember/759609b4bd8e134c02d2fb6118252ef7 to your computer and use it in GitHub Desktop.
matchURI Test Suite
import assert from 'assert';
import { matchURI } from './matchURI.mjs';
assert.deepStrictEqual(matchURI('UNPARSEABLE'), {
uri: 'UNPARSEABLE',
id: undefined,
reason: 'error',
});
assert.deepStrictEqual(matchURI('https://stealth.mil/resource/SECRET'), {
uri: 'https://stealth.mil/resource/SECRET',
id: undefined,
reason: 'none',
});
assert.deepStrictEqual(matchURI('https://example.com'), {
uri: 'https://example.com',
id: undefined,
reason: 'hostname',
});
assert.deepStrictEqual(matchURI('http://alternate.net/resource/RESOURCE/'), {
uri: 'http://alternate.net/resource/RESOURCE/',
id: 'RESOURCE',
reason: 'pathname',
});
assert.deepStrictEqual(matchURI('https://example.com/process/resource/query?id=QUERY'), {
uri: 'https://example.com/process/resource/query?id=QUERY',
id: 'QUERY',
reason: 'param',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment