fix(routes/lovelive-anime): correct relative img URL resolving (#19916)

This fixes img URL for base url ending with slash (`topics/` or `news/`)
This commit is contained in:
Yufan You 2025-08-27 19:34:39 +08:00 committed by GitHub
parent 54dae2a0e4
commit aae0386d9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 6 deletions

View File

@ -109,12 +109,11 @@ async function handler(ctx) {
const pubDate = timezone(parseDate(item.find('a > p.date').text(), 'YYYY/MM/DD'), +9);
const title = item.find('a > p.title').text();
const category = item.find('a > p.category').text();
const imglink = `${rootUrl}/${
item
.find('a > img')
.attr('style')
.match(/background-image:url\((.*)\)/)[1]
}`;
const relativeImgLink = item
.find('a > img')
.attr('style')
.match(/background-image:url\((.*)\)/)[1];
const imglink = new URL(relativeImgLink, baseUrl).href;
return {
link,