Generalize & clean up url parsing
Generalize & clean up url parsing

Also submitted similar code to node core in
https://github.com/joyent/node/pull/7878

eevans/restbase,d00rman/restbase,Krenair/restbase,hardikj/restbase,wikimedia/restbase,inverno/restbase,gwicke/restbase,Pchelolo/restbase,Pchelolo/restbase,milimetric/restbase,wikimedia/hyperswitch,wikimedia/restbase,milimetric/restbase,physikerwelt/restbase,wikimedia/mediawiki-services-restbase,cscott/restbase,cscott/restbase,eevans/restbase,inverno/restbase,gwicke/restbase,d00rman/restbase,hardikj/restbase,Krenair/restbase,wikimedia/mediawiki-services-restbase,physikerwelt/restbase