in src/middleware/redirects.js [52:102]
Redirect.prototype.test = function(url) {
let qs = "";
if (url.indexOf("?") >= 0) {
const parts = url.split("?");
url = parts[0];
qs = parts[1];
}
let match;
if (this.capture) {
match = this.capture.exec(url);
}
if (match) {
let params = {};
if (this.engine === "glob") {
for (let i = 0; i < this.captureKeys.length; i++) {
let m = match[i + 1];
if (m && m.indexOf("/") >= 0) {
m = m.split("/");
}
params[this.captureKeys[i].name] = m;
}
} else {
for (let j = 0; j < match.length; j++) {
params[j.toString()] = match[j];
}
if (match.groups) {
params = Object.assign(params, match.groups);
}
}
try {
const dest = decodeURIComponent(this.compileDestination(params));
return {
type: this.type,
destination: encodeURI(addQuery(dest, qs))
};
} catch (e) {
return undefined;
}
} else if (
patterns.configMatcher(url, { glob: this.glob, regex: this.regex })
) {
return {
type: this.type,
destination: encodeURI(addQuery(this.destination, qs))
};
}
return undefined;
};