AS3 - URL Class

I could not find it in the net so I hacked something together quickly. A simple URL class that parses an url string.

Actionscript:
  1. /* example usage */
  2. var url:URL = new URL("http://secretuser:secretpass@example.com:80/foo/bar.php?var1=foo#abc");
  3. trace(  'scheme:'+url.scheme+'\n'
  4.         + 'host:'+url.host+'\n'
  5.         + 'port:'+url.port+'\n'
  6.         + 'path:'+url.path+'\n'
  7.         + 'fragment:'+url.fragment+'\n'
  8.         + '---\n'
  9.         + 'user:'+url.userinfo.user+'\n'
  10.         + 'pass:'+url.userinfo.pass+'\n'
  11.         + '---\n'
  12.         + 'query.raw:'+url.query.raw+'\n'
  13.         + 'query.parsed.var1:'+url.query.parsed.var1+'\n'
  14.         + 'query.parsed.var2:'+url.query.parsed.var2+'\n'
  15. );

Get it if you have some use for it: http://dev.dschini.org/as3/URL.as (before it gets lost in my archive)

Add a Comment