nodejs获取当前网页的url 以及查看该url中是否包含某个字符串

let url = request.headers.referer;

console.log(url)

(输出值为:http://xx.com/phone/)

2、查看输出中是否有‘/phone/’

url.indexOf("/phone/")

如果不存在则返回-1,如果存在则返回该字符串在url中第一次出现的位置(>-1)

原文地址:https://www.cnblogs.com/KnowEditByW/p/8758266.html