Skip to content

Commit 62590cc

Browse files
heiskrvanessayuenn
andauthored
getPathWithoutLanguage, remove split-slice-join pattern (#16914)
Co-authored-by: Vanessa Yuen <6842965+vanessayuenn@users.noreply.github.com>
1 parent d891618 commit 62590cc

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

lib/path-utils.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ function getPathWithLanguage (href, languageCode) {
7171
// remove the language from the given HREF
7272
// /articles/foo -> /en/articles/foo
7373
function getPathWithoutLanguage (href) {
74-
const newHref = href.match(patterns.hasLanguageCode)
75-
? '/' + href.split('/').slice(2).join('/')
76-
: href
77-
78-
return slash(newHref)
74+
return slash(href.replace(patterns.hasLanguageCode, '/'))
7975
}
8076

8177
function getPathWithoutVersion (href) {

0 commit comments

Comments
 (0)