"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const url_1 = require("../../utils/url"); const lodash_1 = require("lodash"); async function matchUsingFunctionOptions(rule, requestInfo) { return !!await rule.options.call(rule, requestInfo); } function matchUrl(optionValue, checkedValue) { if (optionValue === void 0) return true; if (typeof optionValue === 'string') { optionValue = (0, url_1.ensureOriginTrailingSlash)(optionValue); return optionValue === checkedValue; } else if ((0, lodash_1.isRegExp)(optionValue)) return optionValue.test(checkedValue); return false; } function matchMethod(optionValue, checkedValue) { if (optionValue === void 0) return true; if (typeof optionValue === 'string') return optionValue === checkedValue; return false; } function matchIsAjax(optionValue, checkedValue) { if (optionValue === void 0) return true; if (typeof optionValue === 'boolean') return optionValue === checkedValue; return false; } function matchUsingObjectOptions(rule, requestInfo) { const ruleOptions = rule.options; return matchUrl(ruleOptions.url, requestInfo.url) && matchMethod(ruleOptions.method, requestInfo.method) && matchIsAjax(ruleOptions.isAjax, requestInfo.isAjax); } async function default_1(rule, requestInfo) { if ((0, lodash_1.isFunction)(rule.options)) return matchUsingFunctionOptions(rule, requestInfo); return matchUsingObjectOptions(rule, requestInfo); } exports.default = default_1;module.exports = exports.default;