Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pattern (regex) does not return consistent output when using the global modifier #1190

Open
brendonboshell opened this issue Jul 18, 2023 · 0 comments
Labels

Comments

@brendonboshell
Copy link

In this example:

const s = require("superstruct");

const Query = s.object({
  url: s.pattern(s.string(), /^example/g),
});

const testQuery = {
  url: "example",
};

console.log(s.is(testQuery, Query), s.is(testQuery, Query));

It returns the following output:

% node index.js
true false

I would expect each call to is to return the same output. I suspect this is because of the stateful behaviour of regular expressions.

@arturmuller arturmuller added the bug label Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants