Skip to content

Regex /i flag not working #436

Closed
Closed
@9er-tom

Description

@9er-tom

Environment

nuxt@3.12.3
vue@3.5.13
@vueform/nuxt@1.7.0
vueform@1.11.0

Reproduction

https://stackblitz.com/edit/github-l6wiwpjl?file=src%2FApp.vue

Describe the bug

'/i' flag in regex validation rule seems to do nothing. As seen in the Stackblitz, entering lowercase 'gnd' in the first TextElement should pass validation, as /i flag is set in regex.

To confirm, the same regex passes on regex101

https://regex101.com/r/Aeyzt1/1

This is especially bizarre, as the /i flag is even showcased in Vueform doc for regex patterns
https://vueform.com/docs/validating-elements#rule-regex

Additional context

seems like the problem lies in the .replace of src/services/validation/rules/regex.js

Executing this

var regex = new RegExp('/^GND$/i'.replace(/^\/|\/[^\/]*$/g, ''));
console.log(regex, regex.test('gnd'));

results in this print: /^GND$/ false
the /i flag is removed by the replacement regex

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy