Add local routing rules to Harbor
All checks were successful
Build and Deploy Gateway / build-and-push (push) Successful in 17s
Build and Deploy Gateway / deploy (push) Successful in 6s

This commit is contained in:
2026-07-11 21:52:03 +03:00
parent 306a9b8ced
commit a0c66edb02
17 changed files with 823 additions and 26 deletions

View 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/,
);
});