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

Url validator fails for compare url and shas with the number 3 in them #245

Open
mokkabonna opened this issue Dec 14, 2017 · 0 comments
Open

Comments

@mokkabonna
Copy link
Contributor

mokkabonna commented Dec 14, 2017

The expresstion: [^\.{3}] used in the compare url regexp does not mean what I think you assume it means.

I assume you mean: match anything that does not match three dots in a row.

What it does mean is: match anything but: period, {, 3, }

Also the \ isn't needed when inside a character set

https://www.regular-expressions.info/charclass.html

The usual metacharacters are normal characters inside a character class, and do not need to be escaped by a backslash.

See demo here: Also see a suggestion for an alternative regexp. It allows to my knowledge all chars like dots (in tags, but not multiple in a row) and dashes, underscore etc in branch name/tags.

https://jsfiddle.net/4ros0p8d/3/

([^.]\.?)+(?!\.(?!\.))\.{3}([^.]\.?)+(?!\.) should imo match the desired urls.

([^.]\.?)+  // match anything except a dot, and then a dot :)
(?!\.      // don't match something that has an extra dot
(?!\.))     // except if it has a third dot, then we are cool, let the first expression match all until ..., including single dots
\.{3}       // the three dots
([^.]\.?)+  // same as first
(?!\.)      // simpler pattern for not matching two dots, don't need to check for 3 dots anymore

It's a bit funky with the negative lookahead inside the negative lookahead, but does the trick. It is needed to cancel out the first negative lookahead if it has a total of three dots.

@mokkabonna mokkabonna changed the title Url validator fails for shas with the number 3 in them Url validator fails for compare url and shas with the number 3 in them Dec 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant