Skip to content

Commit 06a89bc

Browse files
committedOct 20, 2022
tolerate extra '/'s in unfurler requests
1 parent 9bb8973 commit 06a89bc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎unfurler/src/language/lang.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ export const languages = languageDict;
6262

6363
// expects path to start with a leading '/'
6464
export function parseLanguageUrl(path) {
65-
const parts = path.split('/');
65+
const parts = path.split('/').filter(part => part.length);
6666
let lang;
6767
let rest;
68-
if (languages[parts[1]]) {
69-
lang = parts[1];
70-
rest = '/' + parts.slice(2).join('/');
68+
if (languages[parts[0]]) {
69+
lang = parts[0];
70+
rest = '/' + parts.slice(1).join('/');
7171
} else {
7272
lang = null;
73-
rest = path;
73+
rest = '/' + parts.join('/');
7474
}
7575
if (lang === 'en') {
7676
lang = null;

0 commit comments

Comments
 (0)
Please sign in to comment.