Skip to content

Commit

Permalink
fix(rel): fix bug causes by sitemap.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
uiolee committed Apr 12, 2023
1 parent 59f60d2 commit e14c3f3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ function relSitemapInject(data) {

if (!rel || data.match(/rel=['|"]?sitemap['|"]?/i)) return;

const relSitemap = `<link rel="sitemap" type="application/xml" title="Sitemap" href="${url_for.call(this, path)}">`;
const relPath = typeof path === 'string' ? path : path[0];
const relSitemap = `<link rel="sitemap" type="application/xml" title="Sitemap" href="${url_for.call(this, relPath)}">`;

return data.replace(/<head>(?!<\/head>).+?<\/head>/s, str => str.replace('</head>', `${relSitemap}</head>`));
}
Expand Down

0 comments on commit e14c3f3

Please sign in to comment.