简体   繁体   中英

Normalizing the URL using javascript (Node.js)

1) How to normalize the url? for example if input is cnn.com

output should be https://www.edition.cnn.com (<- this is the url of cnn.com ) is there any library in node.j?

what i found is "normalize-url" library https://www.npmjs.com/package/normalize-url

what it does is, It is taking url as a input but won't append the www to the url for example input is google.com

output is :-

http://google.com

If you look at the library of normailze-url there are options you can use eg normalizeUrl(url, { stripWWW: false }). then you get your www Regards mathias

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM