1
0
mirror of https://github.com/koloml/furbooru-tagging-assistant.git synced 2026-02-06 23:32:58 +00:00

2 Commits

Author SHA1 Message Date
d5dee6c615 Replaced custom-made RegExp escaping utility with @std/regexp 2025-04-08 19:18:27 +04:00
2da37e2316 Installed @std/regexp 1.0.1 from JSR
This is a part of the Deno's bundle of standard libraries, so it should
be somewhat trustworthy. For now, it only includes the escaping function
which I actually need.
2025-04-08 19:16:58 +04:00
5 changed files with 10 additions and 19 deletions

1
.npmrc
View File

@@ -1 +1,2 @@
engine-strict=true
@jsr:registry=https://npm.jsr.io

7
package-lock.json generated
View File

@@ -9,6 +9,7 @@
"version": "0.4.4",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.7.2",
"@std/regexp": "npm:@jsr/std__regexp@^1.0.1",
"lz-string": "^1.5.0"
},
"devDependencies": {
@@ -1071,6 +1072,12 @@
"win32"
]
},
"node_modules/@std/regexp": {
"name": "@jsr/std__regexp",
"version": "1.0.1",
"resolved": "https://npm.jsr.io/~/11/@jsr/std__regexp/1.0.1.tgz",
"integrity": "sha512-AnGeP//DHpPvhCWjI5dR4o013JhCQioD8yMF8drD7PWb0X4kvmO35hbZi+NZhfSolz4Ts2cpPzJY+DUpi2XE9A=="
},
"node_modules/@sveltejs/acorn-typescript": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.5.tgz",

View File

@@ -31,6 +31,7 @@
"type": "module",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.7.2",
"@std/regexp": "npm:@jsr/std__regexp@^1.0.1",
"lz-string": "^1.5.0"
}
}

View File

@@ -1,6 +1,6 @@
import type { TagDropdownWrapper } from "$lib/components/TagDropdownWrapper";
import TagGroup from "$entities/TagGroup";
import { escapeRegExp } from "$lib/utils";
import { escape as escapeRegExp } from "@std/regexp";
import { emit } from "$lib/components/events/comms";
import { EVENT_TAG_GROUP_RESOLVED } from "$lib/components/events/tag-dropdown-events";

View File

@@ -21,21 +21,3 @@ export function findDeepObject(targetObject: Record<string, any>, path: string[]
return result;
}
/**
* Matches all the characters needing replacement.
*
* Gathered from right here: https://stackoverflow.com/a/3561711/16048617. Because I don't want to introduce some
* library for that.
*/
const unsafeRegExpCharacters: RegExp = /[/\-\\^$*+?.()|[\]{}]/g;
/**
* Escape all the RegExp syntax-related characters in the following value.
* @param value Original value.
* @return Resulting value with all needed characters escaped.
*/
export function escapeRegExp(value: string): string {
unsafeRegExpCharacters.lastIndex = 0;
return value.replace(unsafeRegExpCharacters, "\\$&");
}