Skip to content

Commit

Permalink
PB-871 : code clean-up
Browse files Browse the repository at this point in the history
moving slash enforcing function back to where other base URLs are in the config
  • Loading branch information
pakb committed Aug 23, 2024
1 parent 99dc934 commit 6e16b4f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/api/features/features.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ export function extractOlFeatureGeodesicCoordinates(feature) {
* @param {Number} [offset] Offset of how many items the identification should start after. This
* enables us to do some "pagination" or "load more" (if you already have 10 features, set an
* offset of 10 to get the 10 next, 20 in total).
* @param {String | null} [api3UrlOverride=null] The base URL to access API3 services. If none is
* given, the default from config.js will be used. Default is `null`
* @returns {Promise<LayerFeature[]>}
*/
export async function identifyOnGeomAdminLayer({
Expand Down
13 changes: 12 additions & 1 deletion src/config/baseUrl.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import { enforceEndingSlashInUrl } from '@/config'
/**
* Adds a slash at the end of the URL if there is none
*
* @param {String} url
* @returns {String} The URL with a trailing slash
*/
export function enforceEndingSlashInUrl(url) {
if (url && !url.endsWith('/')) {
return `${url}/`
}
return url
}

/**
* All default base URLs for services.
Expand Down
12 changes: 0 additions & 12 deletions src/config/index.js

This file was deleted.

7 changes: 5 additions & 2 deletions src/modules/menu/components/debug/BaseUrlOverrideModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { computed, ref } from 'vue'
import { useStore } from 'vuex'
import { enforceEndingSlashInUrl } from '@/config'
import { baseUrlOverrides, defaultBaseUrlConfig } from '@/config/baseUrl.config'
import {
baseUrlOverrides,
defaultBaseUrlConfig,
enforceEndingSlashInUrl,
} from '@/config/baseUrl.config'
import ModalWithBackdrop from '@/utils/components/ModalWithBackdrop.vue'
const dispatcher = { dispatcher: 'BaseUrlOverrideModal.vue' }
Expand Down
4 changes: 2 additions & 2 deletions src/router/storeSync/BaseUrlOverrideParamConfig.class.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { baseUrlOverrides } from '@/config/baseUrl.config'
import { baseUrlOverrides, enforceEndingSlashInUrl } from '@/config/baseUrl.config'
import AbstractParamConfig from '@/router/storeSync/abstractParamConfig.class'

export default function createBaseUrlOverrideParamConfig({ urlParamName, baseUrlPropertyName }) {
function dispatchBaseUrlOverride(to, store, urlParamValue) {
baseUrlOverrides[baseUrlPropertyName] = urlParamValue
baseUrlOverrides[baseUrlPropertyName] = enforceEndingSlashInUrl(urlParamValue)
store.dispatch('setHasBaseUrlOverrides', { hasBaseUrlOverrides: !!urlParamValue })
}

Expand Down

0 comments on commit 6e16b4f

Please sign in to comment.