��──────────────────────────────────────┘
</code></pre>

<p>The <code>URL</code> object representation of a URL can also be used to change those parts:</p>

<pre><code>var URL = require('url').URL;
var myURL = new URL('http://www.example.com/foo?bar=1#main');

myURL.protocol = 'https';

myURL.search = '?newBar=2';

console.log(myURL.href);

// prints 'https://www.example.com/foo?newBar=2#main'
</code></pre>

<p>Learn more about wo