Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Go to Spaces
Ctrl+Alt+P
const { URL } = require('url'); // Using the WHATWG URL API (recommended for new code) const myURL = new URL('https://example.org:8080/p/a/t/h?query=string#hash'); console.log(myURL.hostname); // 'example.org' console.log(myURL.pathname); // '/p/a/t/h' console.log(myURL.searchParams.get('query')); // 'string' // Using the legacy API const parsedUrl = require('url').parse('https://example.org:8080/p/a/t/h?query=string#hash'); console.log(parsedUrl.host); // 'example.org:8080' console.log(parsedUrl.query); // 'query=string'
example.org /p/a/t/h string example.org:8080 query=string