Skip to content

Commit

Permalink
support asterisk & trailing slash for exclude pathname
Browse files Browse the repository at this point in the history
  • Loading branch information
jemikanegara committed Nov 18, 2024
1 parent 282982d commit 3198658
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/translation/isExcluded.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ function isExcludedPath(window) {
const globalseoOptions = getGlobalseoOptions(window);
const path = window.location.pathname;

return globalseoOptions.excludePaths.length && globalseoOptions.excludePaths.some(excludePath => excludePath && path.startsWith(excludePath))
return globalseoOptions.excludePaths.length && globalseoOptions.excludePaths.some(excludePath => {
if (!excludePath) return false;
const isEndedWithStar = excludePath.endsWith('/*');
if (isEndedWithStar) return path.startsWith(excludePath.slice(0, -1));
const isEndedWithSlash = excludePath.endsWith('/');
const withoutSlashPath = isEndedWithSlash ? excludePath.slice(0, -1) : excludePath;
return (path === excludePath) || (path == withoutSlashPath);
})
}
exports.isExcludedPath = isExcludedPath;

0 comments on commit 3198658

Please sign in to comment.