@bscotch/cl2-string-server-shared
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -6,3 +6,4 @@ // Modified from https://www.npmjs.com/package/html-escaper | ||
const es = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34);/g; | ||
const ca = /[&<>'"]/g; | ||
// const ca = /[&<>'"]/g; | ||
const ca = /[&<>"]/g; | ||
const esca = { | ||
@@ -12,3 +13,3 @@ '&': '&', | ||
'>': '>', | ||
"'": ''', | ||
// "'": ''', // No real benefit to doing this, and messes up spellcheck etc on HTML content | ||
'"': '"', | ||
@@ -15,0 +16,0 @@ }; |
@@ -20,2 +20,10 @@ export type AsyncFunction = (...args: any[]) => Promise<any>; | ||
/** | ||
* Given a string, prefix all RegExp special characters within it with | ||
* a backslash so that the string can be converted into a RegExp pattern | ||
* with all characters treated as literals. | ||
* | ||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping | ||
*/ | ||
export declare function escapeRegExpSpecialCharacters(string: string): string; | ||
/** | ||
* Convert a string pattern (e.g. "/foo/i") into a RegExp. | ||
@@ -22,0 +30,0 @@ */ |
@@ -61,2 +61,12 @@ import { marked } from 'marked'; | ||
/** | ||
* Given a string, prefix all RegExp special characters within it with | ||
* a backslash so that the string can be converted into a RegExp pattern | ||
* with all characters treated as literals. | ||
* | ||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#escaping | ||
*/ | ||
export function escapeRegExpSpecialCharacters(string) { | ||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string | ||
} | ||
/** | ||
* Convert a string pattern (e.g. "/foo/i") into a RegExp. | ||
@@ -63,0 +73,0 @@ */ |
{ | ||
"name": "@bscotch/cl2-string-server-shared", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "", | ||
@@ -45,4 +45,5 @@ "keywords": [], | ||
"dev": "tsc -w", | ||
"test": "node -r source-map-support/register --test dist" | ||
"test": "node -r source-map-support/register --test dist", | ||
"test:dev": "node -r source-map-support/register --test-only --test dist" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1394759
55050