Code Monkey home page Code Monkey logo

Comments (4)

joseluisq avatar joseluisq commented on May 29, 2024

Confirmed in Google Chrome 76 and Mozilla Firefox 69.0:

const URL_LONG = /^(((http[s]?)|file):)?(\/\/)+([0-9a-zA-Z-_.=?&].+)$/g
const URL_SHORT = /^([\.]?\/)([0-9a-zA-Z-_.=?&]+\/)*([0-9a-zA-Z-_.=?&]+)$/g
const isValidURL = (str) => (URL_LONG.test(str) || URL_SHORT.test(str))
// undefined
isValidURL("https://.../css/chunk-04aba45e.8c018d83.css")
// true
isValidURL("https://.../css/chunk-019a112c.78b8d35d.css")
// false
URL_LONG.test("https://.../css/chunk-019a112c.78b8d35d.css")
// true

from printd.

joseluisq avatar joseluisq commented on May 29, 2024

Using arrow function isValidURL() together with the two RegExs is returning a wrong result.
But it works using a conventional anonymous function.

Tested in Google Chrome 76 and Mozilla Firefox 69.0:

const isValidURL2 = function (str: string) {
  return (URL_LONG.test(str) || URL_SHORT.test(str))
}
// undefined
isValidURL2("https://.../css/chunk-019a112c.78b8d35d.css")
// true
isValidURL2("https://.../css/chunk-04aba45e.8c018d83.css")
// true

from printd.

joseluisq avatar joseluisq commented on May 29, 2024

This is very weird behaviour. I'm going to prepare a bugfix commit for this.

from printd.

joseluisq avatar joseluisq commented on May 29, 2024

Fixed in new release v1.4.1

from printd.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.