Return to Snippet

Revision: 12811
at March 29, 2009 17:27 by Sephr


Initial Code
/^([\w-]+:\/*\[?[\w\.:-]+\]?(?::\d+)?).*/

Initial URL


Initial Description
Use this to extract an HTML5 origin from a URI. $1 is the origin.

The square brackets are there to support IPv6 addresses.

Example:

    var html5OriginRegex = /^([\w-]+:\/*\[?[\w\.:-]+\]?(?::\d+)?).*/;
    "http://www.google.com:42/foo/bar/baz.html".replace(html5OriginRegex, "$1")
    == "http://www.google.com:42"

Initial Title
Get HTML5 origin

Initial Tags
html5

Initial Language
Regular Expression