Skip to content

Commit

Permalink
Fixed internal url to tbProcessor to new url serverside (#2907)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssb-cgn authored Sep 17, 2024
1 parent 0250580 commit 3d6be36
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/resources/lib/ssb/dataset/tbprocessor/tbprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ function getDataAndMetaData(
dataSource.tbprocessor &&
isUrl(dataSource.tbprocessor.urlOrId)
) {
tbmlDataUrl = `${dataSource.tbprocessor.urlOrId as string}${language === 'en' ? `?lang=${language}` : ''}`
sourceListUrl = `${dataSource.tbprocessor.urlOrId as string}`.replace(dataPath, sourceListPath)
const tbprocessorUrl = fixTbProcessorUrl(dataSource.tbprocessor.urlOrId as string)
tbmlDataUrl = `${tbprocessorUrl}${language === 'en' ? `?lang=${language}` : ''}`
sourceListUrl = `${tbprocessorUrl}`.replace(dataPath, sourceListPath)
}

const tbmlParsedResponse: TbprocessorParsedResponse<TbmlDataUniform> | null = tryRequestTbmlData<TbmlDataUniform>(
Expand Down Expand Up @@ -218,6 +219,19 @@ function addSourceList(
: null
}

function fixTbProcessorUrl(url: string): string {
if (url.includes('/i.test.ssb.no')) {
return url.replace('/i.test.ssb.no', '/ext-i.test.ssb.no')
}
if (url.includes('/i.qa.ssb.no')) {
return url.replace('/i.qa.ssb.no', '/ext-i.qa.ssb.no')
}
if (url.includes('/i.ssb.no')) {
return url.replace('/i.ssb.no', '/ext-i.ssb.no')
}
return url
}

export function fetchTbprocessorData(
content: Content<DataSource>,
processXml?: string
Expand Down

0 comments on commit 3d6be36

Please sign in to comment.