Skip to content

Commit

Permalink
Merge pull request #115 from episerver/bugfix/AFORM-4022-Not_render_f…
Browse files Browse the repository at this point in the history
…orm_on_language_code_format_=_##-##

Fix parse language code param allow ##-## format
  • Loading branch information
Tson-optimizely authored Apr 4, 2024
2 parents e5a9109 + 69f40b8 commit d3058f2
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 d3058f2

Please sign in to comment.