0

I need to validate URI and URL in Javascript with the same format as java.net.URI

I think ** URI.create (value) ** uses https://datatracker.ietf.org/doc/html/rfc2396#appendix-B whose regex is

**^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?**

but what regex does URI.create(value).toURL use?

In JavaScript: Example: this is a new URI, but it is not a URL:

  new URL ("email:pacocom@fakeemail.com")

Example: this is a URI and a URL:

  new RegExp ("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?")

I just want URL regular expression for URI.create (value).toURL

Thanks!

pacocom
  • 150
  • 1
  • 6

0 Answers0