From 6226e746bd9f58cf0e5a67a4a66547f7c86240a3 Mon Sep 17 00:00:00 2001 From: azu Date: Wed, 18 May 2022 08:31:34 +0900 Subject: [PATCH] feat: `u` flag by default --- src/regexp-string-matcher.ts | 2 +- .../unicode-by-default-regexp/input-patterns.json | 3 +++ test/snapshots/unicode-by-default-regexp/input.txt | 1 + .../unicode-by-default-regexp/output-for-human.md | 11 +++++++++++ .../unicode-by-default-regexp/output-for-machine.json | 8 ++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/snapshots/unicode-by-default-regexp/input-patterns.json create mode 100644 test/snapshots/unicode-by-default-regexp/input.txt create mode 100644 test/snapshots/unicode-by-default-regexp/output-for-human.md create mode 100644 test/snapshots/unicode-by-default-regexp/output-for-machine.json diff --git a/src/regexp-string-matcher.ts b/src/regexp-string-matcher.ts index 9a5ad28..fcdae55 100644 --- a/src/regexp-string-matcher.ts +++ b/src/regexp-string-matcher.ts @@ -5,7 +5,7 @@ import escapeStringRegexp from "escape-string-regexp"; import { isRegExpString, parseRegExpString } from "./regexp-parse"; import toRegex from "to-regex"; -const DEFAULT_FLAGS = "g"; +const DEFAULT_FLAGS = "ug"; const defaultFlags = (flagsString: string) => { if (flagsString.length === 0) { diff --git a/test/snapshots/unicode-by-default-regexp/input-patterns.json b/test/snapshots/unicode-by-default-regexp/input-patterns.json new file mode 100644 index 0000000..eae3f83 --- /dev/null +++ b/test/snapshots/unicode-by-default-regexp/input-patterns.json @@ -0,0 +1,3 @@ +[ + "/\uD834\uDF06{3}/" +] diff --git a/test/snapshots/unicode-by-default-regexp/input.txt b/test/snapshots/unicode-by-default-regexp/input.txt new file mode 100644 index 0000000..0e0ef8b --- /dev/null +++ b/test/snapshots/unicode-by-default-regexp/input.txt @@ -0,0 +1 @@ +𝌆𝌆𝌆 diff --git a/test/snapshots/unicode-by-default-regexp/output-for-human.md b/test/snapshots/unicode-by-default-regexp/output-for-human.md new file mode 100644 index 0000000..2815270 --- /dev/null +++ b/test/snapshots/unicode-by-default-regexp/output-for-human.md @@ -0,0 +1,11 @@ + +- match text: **𝌆𝌆𝌆** +- captures: **[]** +- startIndex: **0** +- endIndex: **6** + +``` +**𝌆𝌆𝌆** + +``` + diff --git a/test/snapshots/unicode-by-default-regexp/output-for-machine.json b/test/snapshots/unicode-by-default-regexp/output-for-machine.json new file mode 100644 index 0000000..de09c9e --- /dev/null +++ b/test/snapshots/unicode-by-default-regexp/output-for-machine.json @@ -0,0 +1,8 @@ +[ + { + "match": "𝌆𝌆𝌆", + "captures": [], + "startIndex": 0, + "endIndex": 6 + } +] \ No newline at end of file