Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.generateRegexpuOptions = generateRegexpuOptions;
|
---|
7 |
|
---|
8 | var _features = require("./features");
|
---|
9 |
|
---|
10 | function generateRegexpuOptions(node, features) {
|
---|
11 | let useUnicodeFlag = false,
|
---|
12 | dotAllFlag = false,
|
---|
13 | unicodePropertyEscape = false,
|
---|
14 | namedGroup = false;
|
---|
15 | const {
|
---|
16 | flags,
|
---|
17 | pattern
|
---|
18 | } = node;
|
---|
19 | const flagsIncludesU = flags.includes("u");
|
---|
20 |
|
---|
21 | if (flagsIncludesU) {
|
---|
22 | if (!(0, _features.hasFeature)(features, _features.FEATURES.unicodeFlag)) {
|
---|
23 | useUnicodeFlag = true;
|
---|
24 | }
|
---|
25 |
|
---|
26 | if ((0, _features.hasFeature)(features, _features.FEATURES.unicodePropertyEscape) && /\\[pP]{/.test(pattern)) {
|
---|
27 | unicodePropertyEscape = true;
|
---|
28 | }
|
---|
29 | }
|
---|
30 |
|
---|
31 | if ((0, _features.hasFeature)(features, _features.FEATURES.dotAllFlag) && flags.indexOf("s") >= 0) {
|
---|
32 | dotAllFlag = true;
|
---|
33 | }
|
---|
34 |
|
---|
35 | if ((0, _features.hasFeature)(features, _features.FEATURES.namedCaptureGroups) && /\(\?<(?![=!])/.test(pattern)) {
|
---|
36 | namedGroup = true;
|
---|
37 | }
|
---|
38 |
|
---|
39 | if (!namedGroup && !unicodePropertyEscape && !dotAllFlag && (!flagsIncludesU || useUnicodeFlag)) {
|
---|
40 | return null;
|
---|
41 | }
|
---|
42 |
|
---|
43 | if (flagsIncludesU && flags.indexOf("s") >= 0) {
|
---|
44 | dotAllFlag = true;
|
---|
45 | }
|
---|
46 |
|
---|
47 | return {
|
---|
48 | useUnicodeFlag,
|
---|
49 | onNamedGroup: () => {},
|
---|
50 | namedGroup,
|
---|
51 | unicodePropertyEscape,
|
---|
52 | dotAllFlag,
|
---|
53 | lookbehind: true
|
---|
54 | };
|
---|
55 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.