How to use the escapeRegex function from hoek

Find comprehensive JavaScript hoek.escapeRegex code examples handpicked from public code repositorys.

298
299
300
301
302
303
304
305
306
        if (scheme instanceof RegExp) {
            customScheme = customScheme + scheme.source;
        }
        else {
            Hoek.assert(/[a-zA-Z][a-zA-Z0-9+-\.]*/.test(scheme), 'scheme at position ' + i + ' must be a valid scheme');
            customScheme = customScheme + Hoek.escapeRegex(scheme);
        }
    }
}
fork icon0
star icon1
watch icon0

42
43
44
45
46
47
48
49
50
51
};

for (let i = 0; i < settings.origin.length; ++i) {
    const origin = settings.origin[i];
    if (origin.indexOf('*') !== -1) {
        settings._origin.wildcards.push(new RegExp('^' + Hoek.escapeRegex(origin).replace(/\\\*/g, '.*').replace(/\\\?/g, '.') + '$'));
    }
    else {
        settings._origin.qualified.push(origin);
    }
fork icon0
star icon0
watch icon0

155
156
157
158
159
160
161
162
163
164
}
else {
    for (var c = 0, cl = this.settings.cors.origin.length; c < cl; ++c) {
        var origin = this.settings.cors.origin[c];
        if (origin.indexOf('*') !== -1) {
            this.settings.cors._origin.wildcards.push(new RegExp('^' + Hoek.escapeRegex(origin).replace(/\\\*/g, '.*').replace(/\\\?/g, '.') + '$'));
        }
        else {
            this.settings.cors._origin.qualified.push(origin);
        }
fork icon0
star icon0
watch icon3

173
174
175
176
177
178
179
180
181
182
}
else {
    for (var c = 0, cl = cors.origin.length; c < cl; ++c) {
        var origin = cors.origin[c];
        if (origin.indexOf('*') !== -1) {
            cors._origin.wildcards.push(new RegExp('^' + Hoek.escapeRegex(origin).replace(/\\\*/g, '.*').replace(/\\\?/g, '.') + '$'));
        }
        else {
            cors._origin.qualified.push(origin);
        }
fork icon0
star icon0
watch icon2

179
180
181
182
183
184
185
186
187
188
}
else {
    for (var c = 0, cl = settings.cors.origin.length; c < cl; ++c) {
        var origin = settings.cors.origin[c];
        if (origin.indexOf('*') !== -1) {
            settings.cors._origin.wildcards.push(new RegExp('^' + Hoek.escapeRegex(origin).replace(/\\\*/g, '.*').replace(/\\\?/g, '.') + '$'));
        }
        else {
            settings.cors._origin.qualified.push(origin);
        }
fork icon0
star icon0
watch icon0