我在我的节点服务器上工作,遇到需要实现使用request.headers.referer 。 当我testing并读取头文件以确定如何编写parsing函数时,我无法确定从服务器之外,目录之外的链接调用的请求和从给定HTML响应调用本地资源的请求之间的区别。 例如,
使用<a href="http://localhost/dir2">从localhost / dir1到localhost / dir2将产生响应标题:
referer:"http://localhost/dir1" url:"/dir2"
而从localhost / dir2发送的使用本地URI style.css请求资源的HTML文件将是yeild:
referer:"http://localhost/dir2" url:"/style.css"
并且涉及图像的相同情况可能结束
referer:"http://localhost/dir2" url:"/_images/image.png"
我该如何防止解决冲突,在url和referer之间,意外parsing为和parsing为http://localhost/dir1/dir2或http://localhost/_images/image.png等等? 有没有一种方法可以告诉浏览器以何种方式引用URI,当http://localhost/dir2/../dir1是目的地时,浏览器或服务器如何识别?