Posted By

Sephr on 03/29/09


origin html5

Versions (?)

Get HTML5 origin

 / Published in: Regular Expression

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

The square brackets are there to support IPv6 addresses.


var html5OriginRegex = /^([\w-]+:\/*\[?[\w\.:-]+\]?(?::\d+)?).*/;
"".replace(html5OriginRegex, "$1")
== ""
  1. /^([\w-]+:\/*\[?[\w\.:-]+\]?(?::\d+)?).*/

Report this snippet  

You need to login to post a comment.