Files
browser-cli/extension/test/url-match.test.ts
T
daniel156161 6270d8c956
Testing / remote-protocol-compat (0.16.0) (push) Successful in 1m1s
Testing / remote-protocol-compat (0.15.0) (push) Successful in 1m3s
Testing / test (push) Failing after 1m15s
Build & Publish Package / publish (push) Successful in 51s
Package Extension / package-extension (push) Successful in 1m6s
feat: add remote trust and server identity pinning
- Add SSH-style server identity keys and known-host verification for remote serve endpoints.
- Add remote add/list/remove commands for explicit endpoint persistence.
- Fix remote clients listing to fan out through target discovery instead of ambiguous auto-routing.
- Add URL glob matching for tabs filter and count with extension tests.
- Add n8n credential pinning for server public keys or SHA256 fingerprints.
- Remove obsolete compat shim behavior while keeping empty compat seams for future protocol changes.
- Bump browser-cli to 0.16.4 and n8n node to 0.3.1.
- Cover known-hosts, remote registry, compat seams, n8n protocol verification, and URL matching with tests.
2026-06-26 08:53:21 +02:00

44 lines
2.0 KiB
TypeScript

// @ts-nocheck
import test from 'node:test';
import assert from 'node:assert/strict';
import { urlMatchesPattern } from '../src/commands/tabs-query';
const TWITCH = 'https://www.twitch.tv/somechannel';
test('plain pattern is a case-sensitive substring match (historic behavior)', () => {
assert.equal(urlMatchesPattern(TWITCH, 'twitch.tv'), true);
assert.equal(urlMatchesPattern(TWITCH, 'somechannel'), true);
assert.equal(urlMatchesPattern(TWITCH, 'Twitch.tv'), false, 'case-sensitive');
assert.equal(urlMatchesPattern(TWITCH, 'youtube.com'), false);
});
test('glob with /* matches anywhere in the URL', () => {
// The reported case: a glob, not a literal substring.
assert.equal(urlMatchesPattern(TWITCH, 'twitch.tv/*'), true);
assert.equal(urlMatchesPattern('https://www.twitch.tv/', 'twitch.tv/*'), true);
assert.equal(urlMatchesPattern('https://twitch.tv', 'twitch.tv/*'), false, 'no slash → no match');
});
test('leading wildcard and ? wildcard work', () => {
assert.equal(urlMatchesPattern(TWITCH, '*.twitch.tv/*'), true);
assert.equal(urlMatchesPattern('https://a.twitch.tv/x', 'https://?.twitch.tv/*'), true);
assert.equal(urlMatchesPattern('https://ab.twitch.tv/x', 'https://?.twitch.tv/*'), false, '? is one char');
});
test('regex metacharacters in a non-glob pattern stay literal', () => {
assert.equal(urlMatchesPattern('https://x.dev/a.b', 'a.b'), true);
assert.equal(urlMatchesPattern('https://x.dev/axb', 'a.b'), false, 'plain substring is literal — "." is not a regex wildcard');
});
test('regex metacharacters next to a glob are escaped', () => {
// The "." must stay literal even when "*" promotes the pattern to a glob.
assert.equal(urlMatchesPattern('https://x.dev/foo', 'x.dev/*'), true);
assert.equal(urlMatchesPattern('https://xydev/foo', 'x.dev/*'), false, '. does not match y');
});
test('empty url or pattern never matches', () => {
assert.equal(urlMatchesPattern('', 'twitch.tv'), false);
assert.equal(urlMatchesPattern(undefined, 'twitch.tv'), false);
assert.equal(urlMatchesPattern(TWITCH, ''), false);
});