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 69f40b8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/@episerver/forms-sdk/src/helpers/urlHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const extractParams = (urlPath: string) => {
if (relativePath.endsWith('/')) {
relativePath = relativePath.slice(0, -1)
}

if (relativePath.includes(",")) {
const [, , idString] = relativePath.split(",")
if (idString.includes("_")) {
Expand All @@ -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) //##-## format language code, ex: nl-BE, vi-VN,...
)
: "en"

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

0 comments on commit 69f40b8

Please sign in to comment.