splitting a full url into parts : <p>I'm trying to split a url into parts so that I can work with these separately. </p>

<p>For e.g. the url:</p>

<p><code>'https://api.somedomain.co.uk/api/addresses?postcode=XXSDF&amp;houseNo=34'</code></p>

<p>How can I split this into:
1) the source/origin (i.e. protocol + subdomain + domain)
2) path '/api/addresses'
3) Query:  '?postcode=XXSDF&amp;houseNo=34'</p>
