Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Mixed parameter
const seg = {
length: parts.length,
first: typeof parts[0] !== 'string',
segments: []
};
let finger = '';
let regex = '^';
for (let j = 0; j < parts.length; ++j) {
const part = parts[j];
if (typeof part === 'string') {
finger = finger + part;
regex = regex + Hoek.escapeRegex(part);
seg.segments.push(part);
}
else {
Hoek.assert(params.indexOf(part.name) === -1, 'Cannot repeat the same parameter name:', part.name, 'in:', path);
params.push(part.name);
finger = finger + '?';
regex = regex + '(.' + (part.empty ? '*' : '+') + ')';
}
}
seg.mixed = new RegExp(regex + '$', (!this.settings.isCaseSensitive ? 'i' : ''));
fingers.push(finger);
segments.push(seg);
}
}
if (settings.origin === 'ignore') {
settings._origin = false;
}
else if (settings.origin.indexOf('*') !== -1) {
Hoek.assert(settings.origin.length === 1, 'Cannot specify cors.origin * together with other values');
settings._origin = true;
}
else {
settings._origin = {
qualified: [],
wildcards: []
};
for (const origin of settings.origin) {
if (origin.indexOf('*') !== -1) {
settings._origin.wildcards.push(new RegExp('^' + Hoek.escapeRegex(origin).replace(/\\\*/g, '.*').replace(/\\\?/g, '.') + '$'));
}
else {
settings._origin.qualified.push(origin);
}
}
}
return settings;
};