UNPKG

@jsdevtools/rehype-url-inspector

Version:

A rehype plugin to inspect, validate, or rewrite URLs anywhere in an HTML document

42 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NormalizedOptions = void 0; const extractors_1 = require("./extractors"); const selectors_1 = require("./selectors"); /** * Normalized, sanitized, and complete settings, * with default values for anything that wasn't specified by the caller. */ class NormalizedOptions { /** * Applies default values for any unspecified options */ constructor(options = {}) { this.selectors = []; this.extractors = []; this.inspect = options.inspect; this.inspectEach = options.inspectEach; if (options.selectors) { // Split the UrlSelectors from the UrlExtractors for (let selector of options.selectors) { if (typeof selector === "function") { this.extractors.push(selector); } else if (typeof selector === "string") { selector = selectors_1.createUrlSelector(selector); this.selectors.push(selector); } else { this.selectors.push(selector); } } } if (!options.selectors || options.keepDefaultSelectors) { // Add our default selectors and extractors this.selectors.push(...selectors_1.defaultSelectors); this.extractors.push(...extractors_1.defaultExtractors); } } } exports.NormalizedOptions = NormalizedOptions; //# sourceMappingURL=options.js.map