browser-extension-url-match
Version:
Browser extension URL pattern matching
26 lines (25 loc) • 937 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getExampleUrls = getExampleUrls;
var _getDummyUrl = require("./getDummyUrl");
var _getPatternSegments = require("./getPatternSegments");
function getExampleUrls(pattern, options) {
const patternSegments = (0, _getPatternSegments.getPatternSegments)(pattern);
const {
supportedSchemes,
strict
} = options;
const subdomains = ['', 'www', 'foo.bar'];
const rootDomains = ['example.com'];
const pathAndQueryReplacers = ['', 'foo', '/bar/baz/'];
const all = supportedSchemes.flatMap(defaultScheme => subdomains.flatMap(subdomain => rootDomains.flatMap(rootDomain => pathAndQueryReplacers.flatMap(pathAndQueryReplacer => (0, _getDummyUrl.getDummyUrl)(patternSegments, {
defaultScheme,
subdomain,
rootDomain,
pathAndQueryReplacer,
strict
})))));
return [...new Set(all.filter(Boolean).map(url => url.href))];
}
;