/**
* Used by Sidebar.vue
*/
export default {
methods: {
getGeoredV2URL(relativeURL) {
return injectJWTAndLanguageParametersToURL.apply(this, [
(this.$envService.getEnvValue('VUE_APP_GEORED_HOST') ||
window.location.origin) + relativeURL,
])
},
getCitiFretURL(relativeURL) {
return injectJWTAndLanguageParametersToURL.apply(this, [
(this.$envService.getEnvValue('VUE_APP_CITIFRET_HOST') ||
window.location.origin) + relativeURL,
])
},
getCitipavURL() {
return injectJWTAndLanguageParametersToURL.apply(this, [
this.$envService.getEnvValue('VUE_APP_CITIPAV_HOST') ||
window.location.origin,
])
},
},
}
/**
*
* @param {String} url i.g https://dev-geored.geored.fr/desktop
* @example
* Input: https://dev-geored.geored.fr/desktop
* Output: https://dev-geored.geored.fr/desktop?_token=JWT&lg=fr
* @returns
*/
function injectJWTAndLanguageParametersToURL(url) {
//Todo: Move somewhere else
if (url.includes('geored-') && window.location.origin.includes('geotrans')) {
url = url.split('geored-').join('geotrans-')
}
if (url.includes('geotrans-') && window.location.origin.includes('geored')) {
url = url.split('geotrans-').join('geored-')
}
if (
url.includes('geotrans-') &&
window.location.origin.includes('geonline')
) {
url = url.split('geotrans-').join('geored-')
}
if (!url.includes('lg=')) {
url +=
(url.indexOf('?') === -1 ? '?' : '&') +
`lg=${this.$store.getters['settings/getParameter'](
'applicationLanguage'
)}`
}
url +=
(url.indexOf('?') === -1 ? '?' : '&') +
`_token=${this.$store.getters['auth/jwt']}`
return url
}
Source