Skip to content

Instantly share code, notes, and snippets.

@jarridlima
Created January 23, 2020 15:09
Show Gist options
  • Select an option

  • Save jarridlima/965022c848c37919664a47a83c034459 to your computer and use it in GitHub Desktop.

Select an option

Save jarridlima/965022c848c37919664a47a83c034459 to your computer and use it in GitHub Desktop.

Revisions

  1. jarridlima created this gist Jan 23, 2020.
    20 changes: 20 additions & 0 deletions .js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    let patternUrl = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/

    // source: https://www.regextester.com/94502

    // ===============================
    // Test strings:
    // ===============================
    // https://www.example.com
    // http://www.example.com
    // www.example.com
    // example.com
    // http://blog.example.com
    // http://www.example.com/product
    // http://www.example.com/products?id=1&page=2
    // http://www.example.com#up
    // http://255.255.255.255
    // 255.255.255.255
    // http://www.site.com:8008

    // INVALID => http://invalid.com/perl.cgi?key= | http://web-site.com/cgi-bin/perl.cgi?key1=value1&key2