uuidv4.js 正则表达式问题 - IE11 [英] uuidv4.js regular expression issue - IE11

查看:83
本文介绍了uuidv4.js 正则表达式问题 - IE11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在一家公司工作,我必须解决 IE11 的几个问题.问题之一仅存在于 IE11 中,它以来自 node_modules 的 uuidv4 为中心.

I am currently working in a company where I have to fix a couple issue with IE11. One of the issues is only present in IE11 which centers around uuidv4 from node_modules.

出错的代码和我看到的错误是

the code at fault and the error that I am seeing is

正则表达式中的语法错误

Syntax error in regular expression

    /***/ (function (module, exports, __webpack_require__) {

        "use strict";
        //eval("

        var __importDefault = (this && this.__importDefault) || function (mod) {

            return (mod && mod.__esModule) ? mod : {"default": mod };};

            Object.defineProperty(exports, "__esModule", { value: true });
            const v4_1 = __importDefault(__webpack_require__(/*! uuid/v4 */ "../node_modules/uuid/v4.js"));
            const v5_1 = __importDefault(__webpack_require__(/*! uuid/v5 */ "../node_modules/uuid/v5.js"));
            const uuidv4 = function () {
                return v4_1.default();
            };

            uuidv4.regex = {
                v4: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u,
                v5: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-5[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u
            }; uuidv4.is = function (value) {

                return uuidv4.regex.v4.test(value) || uuidv4.regex.v5.test(value); 
            }; uuidv4.empty = function () {
                return '00000000-0000-0000-0000-000000000000';
            };

            uuidv4.fromString = function (text) {
                const namespace = 'bb5d0ffa-9a4c-4d7c-8fc2-0a7d2220ba45';
                const uuidFromString = v5_1.default(text, namespace);
                return uuidFromString;
            };

            exports.default = uuidv4;

            //# sourceURL=webpack://_chex/../node_modules/uuidv4/build/lib/uuidv4.js?");

            /***/
        }),

我确实看到并希望解决此处更改代码中可能存在的问题之一

I did see and look to resolve what could have been one of the problems in the code in here changing

v5:/^(?:[a-f0-9]{8}-[a-f0-9]{4}-5[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u

v5:/^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/你

{4}-5 是这个正则表达式中的违规项,但是 IE11 仍然抱怨同样的问题.

{4}-5 was the offending item in this regex, however IE11 still complains about the same issue.

但仔细检查后,这是它抱怨的线

But on closer inspection this is the line that it is complaining about

v4:/^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/你,

当尝试放置调试器语句时,我无法像到达那里之前那样点击这些语句,并且正在评估代码失败并产生错误.

When trying to put debugger statements in place, I cant hit these as before I get there and the code is being evaluated it fails and produces the error.

将不胜感激地收到有关此的任何和所有帮助.

Any and all help on this will be gratefully received.

推荐答案

/u 修饰符 仅在 ECMAScript 6/ES2015 中引入,并且 IE11 仅支持 ES5 标准.

由于没有使用 u 修饰符标志定义其行为的特定构造,您可以简单地删除 u 并且您的表达式将起作用.

Since there are no specific constructs whose behavior is defined with the u modifier flag, you may simply remove u and your expression will work.

这篇关于uuidv4.js 正则表达式问题 - IE11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆