Compare commits

..

No commits in common. "develop" and "0.25.16" have entirely different histories.

3 changed files with 8 additions and 20 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@ztimson/utils",
"version": "0.25.18",
"version": "0.25.16",
"description": "Utility library",
"author": "Zak Timson",
"license": "MIT",

View File

@ -1,16 +1,6 @@
import {PathEvent} from './path-events.ts';
import {md5} from './string';
/**
* Escape any regex special characters to avoid misinterpretation during search
*
* @param {string} value String which should be escaped
* @return {string} New escaped sequence
*/
export function escapeRegex(value: string) {
return value.replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
}
/**
* Run a stringified function with arguments asynchronously
* @param {object} args Map of key/value arguments
@ -36,15 +26,13 @@ export function gravatar(email: string, def='mp') {
}
/**
* Convert IPv6 to v4 because who uses that, NAT4Life
* @param {string} ip IPv6 address, e.g. 2001:0db8:85a3:0000:0000:8a2e:0370:7334
* @returns {string | null} IPv4 address, e.g. 172.16.58.3
* Escape any regex special characters to avoid misinterpretation during search
*
* @param {string} value String which should be escaped
* @return {string} New escaped sequence
*/
export function ipV6ToV4(ip: string) {
if(!ip) return null;
const ipv4 = ip.split(':').splice(-1)[0];
if(ipv4 == '1') return '127.0.0.1';
return ipv4;
export function escapeRegex(value: string) {
return value.replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
}
/**

View File

@ -157,7 +157,7 @@ export class PathEvent {
const parsedTarget = makeArray(target).map(pe => new PathEvent(pe));
const parsedRequired = makeArray(has).map(pe => new PathEvent(pe));
return !!parsedRequired.find(r => !!parsedTarget.find(t =>
(r.fullPath == '*' || t.fullPath == '*' || r.fullPath.startsWith(t.fullPath)) &&
(r.fullPath == '*' || t.fullPath == '*' || r.fullPath.startsWith(t.fullPath) || t.fullPath.startsWith(r.fullPath)) &&
(r.all || t.all || r.methods.intersection(t.methods).length)
));
}