Skip to content

页面 head 中 设置base 导致 页面内链接解析错误 #142

Open
@seveniu

Description

@seveniu

问题网页网址:http://www.sdsqw.cn/news/hrnews/

head 中设置有 :

<base href="http://www.sdsqw.cn/">

url 应该为 base 中的 url http://www.sdsqw.cn/,而不是 请求的 url http://www.sdsqw.cn/news/hrnews/

String html = "<a href=\"news/hrnews/2014sxszxx/201407/article_29512.html\" target=\"_blank\" class=\"zlk_zi_02\">&nbsp;阳谷县石佛镇《徐楼村志》编纂成书</a>";

String url = "http://www.sdsqw.cn/news/hrnews/";
System.out.println(fixAllRelativeHrefs(html, url));

输出:

<a href="http://www.sdsqw.cn/news/hrnews/news/hrnews/2014sxszxx/201407/article_29512.html" target="_blank" class="zlk_zi_02">&nbsp;阳谷县石佛镇《徐楼村志》编纂成书</a>

应该为:

<a href="http://www.sdsqw.cn/news/hrnews/2014sxszxx/201407/article_29512.html" target="_blank" class="zlk_zi_02">&nbsp;阳谷县石佛镇《徐楼村志》编纂成书</a>

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions