Make ucschars regex smaller.

This commit is contained in:
Caleb 2017-09-30 20:43:29 -06:00
parent 9bc65cd0ac
commit 4e5a004010

View File

@ -14,7 +14,7 @@ export function getNewEntryUrl(collectionName, direct) {
// Unreserved chars from RFC3987. // Unreserved chars from RFC3987.
const uriChars = /[\w\-.~]/i; const uriChars = /[\w\-.~]/i;
const ucsChars = /[\xA0-\u{D7FF}]|[\u{F900}-\u{FDCF}]|[\u{FDF0}-\u{FFEF}]|[\u{10000}-\u{1FFFD}]|[\u{20000}-\u{2FFFD}]|[\u{30000}-\u{3FFFD}]|[\u{40000}-\u{4FFFD}]|[\u{50000}-\u{5FFFD}]|[\u{60000}-\u{6FFFD}]|[\u{70000}-\u{7FFFD}]|[\u{80000}-\u{8FFFD}]|[\u{90000}-\u{9FFFD}]|[\u{A0000}-\u{AFFFD}]|[\u{B0000}-\u{BFFFD}]|[\u{C0000}-\u{CFFFD}]|[\u{D0000}-\u{DFFFD}]|[\u{E1000}-\u{EFFFD}]/u; const ucsChars = /[\xA0-\u{D7FF}\u{F900}-\u{FDCF}\u{FDF0}-\u{FFEF}\u{10000}-\u{1FFFD}\u{20000}-\u{2FFFD}\u{30000}-\u{3FFFD}\u{40000}-\u{4FFFD}\u{50000}-\u{5FFFD}\u{60000}-\u{6FFFD}\u{70000}-\u{7FFFD}\u{80000}-\u{8FFFD}\u{90000}-\u{9FFFD}\u{A0000}-\u{AFFFD}\u{B0000}-\u{BFFFD}\u{C0000}-\u{CFFFD}\u{D0000}-\u{DFFFD}\u{E1000}-\u{EFFFD}]/u;
export function sanitizeIRI(str, { replacement }) { export function sanitizeIRI(str, { replacement }) {
let result = ""; let result = "";
// We cannot use a `map` function here because `string.split()` splits things like emojis into surrogate pairs. // We cannot use a `map` function here because `string.split()` splits things like emojis into surrogate pairs.