@ublacklist/match-pattern
v2.0.0
Published
A parser and lookup map for WebExtensions match patterns.
Maintainers
Readme
@ublacklist/match-pattern
A parser and lookup map for WebExtensions match patterns.
Installation
npm install @ublacklist/match-patternUsage
import {
MatchPattern,
MatchPatternMap,
parseMatchPattern,
} from "@ublacklist/match-pattern";
parseMatchPattern("*://*.example.com/*");
// { allURLs: false, scheme: "*", host: "*.example.com", path: "/*" }
const pattern = new MatchPattern([
"*://*.example.com/*",
"https://example.net/*",
]);
pattern.test("https://www.example.com/"); // true
pattern.test("https://example.org/"); // false
const map = new MatchPatternMap<number>();
map.set("*://*.example.com/*", 1);
map.get("https://www.example.com/"); // [1]