Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery-url in nodejs

Tags:

node.js

npm

I'm trying to port some js code that's using jquery-url into nodejs.

jquery-url is used to get the hostname of a given URL in this way:

var host = $.url(url).attr('host');

My question is, is there a npm package of jquery-url? if not, what already existing package has this functionality?

Thanks in advance!

like image 685
Sergio Ayestarán Avatar asked Aug 25 '26 06:08

Sergio Ayestarán


1 Answers

Node.js already has this build in. See node Documentation.

For Example:

var url = require("url");
var host = url.parse('http://user:[email protected]:8080/p/a/t/h?query=string#hash').host;
console.log(host);
like image 134
Marc Fischer Avatar answered Aug 28 '26 09:08

Marc Fischer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!