How to get the path of a URL in Node.js

1 Answer

0 votes
const url = require('url');

const testurl = new URL('https://www.website.com/orders/index.html?id=8372&age=43')

console.log(testurl.pathname);
  

       
/*
run:
     
/orders/index.html
   
*/

 



answered Mar 10, 2020 by avibootz
edited Mar 10, 2020 by avibootz

Related questions

1 answer 246 views
3 answers 448 views
1 answer 304 views
1 answer 319 views
1 answer 376 views
1 answer 303 views
303 views asked Mar 10, 2020 by avibootz
...