Skip to content

Commit

Permalink
cleanUrl of '/index.html' should be '/'
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Aug 28, 2018
1 parent 8633e00 commit 6e02c49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/core/__tests__/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ describe('utils', () => {
expect(cleanPath('/en/users')).toBe('/en/users');
expect(cleanPath('/docs/versioning.html')).toBe('/docs/versioning');
expect(cleanPath('/en/users.html')).toBe('/en/users');
expect(cleanPath('/docs/en/asd/index.html')).toBe('/docs/en/asd');
expect(cleanPath('/en/help/index.html')).toBe('/en/help');
expect(cleanPath('/docs/en/asd/index.html')).toBe('/docs/en/asd/');
expect(cleanPath('/en/help/index.html')).toBe('/en/help/');
expect(cleanPath('/index.html')).toBe('/');
expect(cleanPath('/react/index.html')).toBe('/react/');
expect(cleanPath('/en/help.a.b.c.d.e.html')).toBe('/en/help.a.b.c.d.e');
expect(cleanPath('/en/help.js')).toBe('/en/help.js');
expect(cleanPath('/test.md')).toBe('/test.md');
Expand Down
2 changes: 1 addition & 1 deletion lib/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getPath(pathStr, cleanUrl = false) {
return pathStr;
}
return pathStr.endsWith('/index.html')
? pathStr.replace(/\/index.html$/, '')
? pathStr.replace(/index\.html$/, '')
: removeExtension(pathStr);
}

Expand Down

0 comments on commit 6e02c49

Please sign in to comment.