Add local routing rules to Harbor
This commit is contained in:
29
test/shared/routing-rules.test.js
Normal file
29
test/shared/routing-rules.test.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { normalizeRouteRules } from '../../src/shared/routingRules.js';
|
||||
|
||||
test('local route rules normalize URLs, suffixes and duplicates', () => {
|
||||
assert.deepEqual(normalizeRouteRules([
|
||||
{ type: 'domain', value: 'https://Example.com/news?id=1' },
|
||||
{ type: 'domain_suffix', value: '*.Example.org' },
|
||||
{ type: 'domain_keyword', value: ' CDN ' },
|
||||
{ type: 'domain', value: 'example.com' },
|
||||
{ type: 'domain_suffix', value: '.ru' },
|
||||
], { strict: true }), [
|
||||
{ type: 'domain', value: 'example.com' },
|
||||
{ type: 'domain_suffix', value: 'example.org' },
|
||||
{ type: 'domain_keyword', value: 'cdn' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('invalid local route rules fail at the strict boundary', () => {
|
||||
assert.throws(
|
||||
() => normalizeRouteRules([{ type: 'domain_regex', value: '.*' }], { strict: true }),
|
||||
/Invalid domain rule type/,
|
||||
);
|
||||
assert.throws(
|
||||
() => normalizeRouteRules([{ type: 'domain_keyword', value: 'bad/path' }], { strict: true }),
|
||||
/Invalid domain rule value/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user