Skip to content

Commit

Permalink
Fix parse language code param allow ##-## format
Browse files Browse the repository at this point in the history
Fixes: AFORM-4022
Story: AFORM-3884
  • Loading branch information
Linh Hoang committed Apr 2, 2024
1 parent 2596edd commit 51f9eff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/@episerver/forms-sdk/src/helpers/urlHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export const extractParams = (urlPath: string) => {
}

const urlSegments = relativePath.split('/')
const language = urlSegments.length ? urlSegments.find(s => s.length === 2) : "en"
let language = urlSegments.length ?
urlSegments.find(s =>
s.length === 2 || //2 letter language code, ex: en, sv,...
(s.indexOf("-") === 2 && s.length === 5) //4 letter language code, ex: nl-BE, vi-VN,...
)
: "en"

return { relativePath, locales: language, language, contentId, workId }
}

0 comments on commit 51f9eff

Please sign in to comment.