fix weird link behavior
This commit is contained in:
parent
5c0113e972
commit
8d0274e00c
1 changed files with 11 additions and 1 deletions
12
site.js
12
site.js
|
@ -24,7 +24,17 @@ async function urlCollector(url, path, file) {
|
|||
let links = body('a');
|
||||
let urls = [];
|
||||
links.each(function(i, link) {
|
||||
urls.push(body(link).attr('href'))
|
||||
let h = body(link).attr('href');
|
||||
if (!h) return;
|
||||
h = h.trim();
|
||||
if (h.startsWith('./') && h.startsWith('../')) {
|
||||
h = `${url}/h`;
|
||||
} else if (h.startsWith('/')) {
|
||||
let u = new URL(url);
|
||||
u.pathname = h;
|
||||
urls.push(u.toString())
|
||||
}
|
||||
urls.push(h)
|
||||
})
|
||||
|
||||
return urls;
|
||||
|
|
Loading…
Reference in a new issue