Using better existing method
This commit is contained in:
parent
1dfbfe7ba5
commit
47e644969d
3 changed files with 3 additions and 32 deletions
|
|
@ -1,8 +0,0 @@
|
|||
/**
|
||||
* Replaces all instances of '/' with '%2F'
|
||||
* @param {string} parameter
|
||||
* @returns string with '/' replaced with '%2F'
|
||||
*/
|
||||
export default function encodeParameter(parameter) {
|
||||
return parameter.split('/').join('%2F')
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import encodeParameter from '@/helpers/url-query-string-encoder';
|
||||
|
||||
describe('url-query-string-encoder', () => {
|
||||
describe('encodeParameter', () => {
|
||||
test.each([
|
||||
['', ''],
|
||||
['/', '%2F'],
|
||||
['// ', '%2F%2F '],
|
||||
['/ap ple', '%2Fap ple'],
|
||||
['ap/ple', 'ap%2Fple'],
|
||||
['apple /', 'apple %2F'],
|
||||
['//a/pp/le/', '%2F%2Fa%2Fpp%2Fle%2F']
|
||||
])('Given %p returns %p', (input, expected) => {
|
||||
// Act
|
||||
var result = encodeParameter(input);
|
||||
|
||||
// Assert
|
||||
expect(result).toEqual(expected);
|
||||
})
|
||||
});
|
||||
})
|
||||
|
|
@ -478,7 +478,7 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
getVehicleModels() {
|
||||
const encodedMake = encodeParameter(this.order.vehicle.make);
|
||||
const encodedMake = encodeURIComponent(this.order.vehicle.make);
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetVehicleModels.method,
|
||||
endpoint: `${endpoints.GetVehicleModels.url}/${this.order.vehicle.year}/${encodedMake}`,
|
||||
|
|
@ -487,8 +487,8 @@ export const useMainStore = defineStore({
|
|||
},
|
||||
|
||||
getVehicleStyles() {
|
||||
const encodedMake = encodeParameter(this.order.vehicle.make);
|
||||
const encodedModel = encodeParameter(this.order.vehicle.model);
|
||||
const encodedMake = encodeURIComponent(this.order.vehicle.make);
|
||||
const encodedModel = encodeURIComponent(this.order.vehicle.model);
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetVehicleStyles.method,
|
||||
endpoint: `${endpoints.GetVehicleStyles.url}/${this.order.vehicle.year}/${encodedMake}/${encodedModel}`,
|
||||
|
|
|
|||
Loading…
Reference in a new issue