[英]Normalizing the URL using javascript (Node.js)
1) How to normalize the url? 1)如何规范化网址? for example if input is cnn.com例如,如果输入是cnn.com
output should be https://www.edition.cnn.com (<- this is the url of cnn.com ) is there any library in node.j?输出应该是https://www.edition.cnn.com (<-这是cnn.com的网址) node.j 中有任何库吗?
what i found is "normalize-url" library https://www.npmjs.com/package/normalize-url
我发现的是“normalize-url”库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它的作用是,它将 url 作为输入,但不会将www附加到 url 例如输入是 google.com
output is :-输出是:-
If you look at the library of normailze-url
there are options you can use eg normalizeUrl(url, { stripWWW: false }).
如果您查看normailze-url
库,您可以使用一些选项,例如normalizeUrl(url, { stripWWW: false }).
then you get your www
Regards mathias然后你会得到你的www
问候 mathias
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.