Skip to content

Commit

Permalink
Remove duplicated slashes
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed May 19, 2018
1 parent ab95670 commit bef90ac
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const shouldRedirect = (rewrittenPath, {redirects = [], trailingSlash = null}) =
}

const defaultType = 301;
console.log(rewrittenPath);

if (typeof trailingSlash === 'boolean') {
const {ext} = path.parse(rewrittenPath);
Expand All @@ -100,6 +99,10 @@ const shouldRedirect = (rewrittenPath, {redirects = [], trailingSlash = null}) =
target = `${rewrittenPath}/`;
}

if (rewrittenPath.indexOf('//') > -1) {
target = rewrittenPath.replace(/\/+/g, '/');
}

if (target) {
return {
target,
Expand Down

0 comments on commit bef90ac

Please sign in to comment.