Compare commits

..

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

2 changed files with 7 additions and 19 deletions

View File

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

View File

@ -1,16 +1,6 @@
import {PathEvent} from './path-events.ts'; import {PathEvent} from './path-events.ts';
import {md5} from './string'; 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 * Run a stringified function with arguments asynchronously
* @param {object} args Map of key/value arguments * @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 * Escape any regex special characters to avoid misinterpretation during search
* @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 * @param {string} value String which should be escaped
* @return {string} New escaped sequence
*/ */
export function ipV6ToV4(ip: string) { export function escapeRegex(value: string) {
if(!ip) return null; return value.replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
const ipv4 = ip.split(':').splice(-1)[0];
if(ipv4 == '1') return '127.0.0.1';
return ipv4;
} }
/** /**