Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/885 encode url #886

Merged
merged 5 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,35 @@
},
"homepage": "https://github.com/chantouchsek/vue-axios-http#readme",
"devDependencies": {
"@commitlint/cli": "^17.0.0",
"@commitlint/config-conventional": "^17.0.0",
"@nuxt/types": "^2.15.8",
"@types/lodash": "^4.14.182",
"@types/node": "^20.2.0",
"@types/qs": "^6.9.7",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.9.0",
"@vitest/coverage-c8": "^0.33.0",
"@vue/test-utils": "^1.3.3",
"axios-mock-adapter": "^1.20.0",
"eslint": "^8.13.0",
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@nuxt/types": "^2.16.3",
"@types/lodash": "^4.14.199",
"@types/node": "^20.7.0",
"@types/qs": "^6.9.8",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vitest/coverage-v8": "^0.34.5",
"@vue/test-utils": "^1.3.6",
"axios-mock-adapter": "^1.22.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"husky": "^8.0.1",
"jsdom": "^22.0.0",
"lint-staged": ">=10",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"husky": "^8.0.3",
"jsdom": "^22.1.0",
"lint-staged": ">=14.0.1",
"nodemon": "^3.0.1",
"nuxt": "^2.15.8",
"prettier": "^2.4.1",
"rimraf": "^5.0.1",
"standard-version": "^9.3.1",
"nuxt": "^2.16.3",
"prettier": "^2.8.8",
"rimraf": "^5.0.4",
"sass": "^1.68.0",
"standard-version": "^9.5.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"vite": "^4.0.4",
"vitest": "^0.31.1",
"vite": "^4.4.9",
"vitest": "^0.34.5",
"vue": "^2.7.14"
},
"files": [
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/base-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ValidatorType } from '../core/Validator'
import Axios from 'axios'
import MockAdapter from 'axios-mock-adapter'
import { merge } from 'lodash'
import { beforeEach, describe, expect, it } from 'vitest'
import BaseService from '../core/BaseService'
import Validator from '../core/Validator'
import PostService from '../util/PostService'
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/form-data.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, expect, it } from 'vitest'
import { objectToFormData } from '../util'

describe('FormData', () => {
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/object.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { afterEach, describe, expect, it } from 'vitest'
import { hasFiles, isFile } from '../util'

describe('Object Test', () => {
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/package.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { mount } from '@vue/test-utils'
import { describe, expect, test } from 'vitest'
import Vue from 'vue'
import AxiosHttp from '../'
import { addElemWithDataAppToBody, disableTransitions, sleep } from '../util'
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/post-service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Axios from 'axios'
import MockAdapter from 'axios-mock-adapter'
import { beforeEach, describe, expect, it } from 'vitest'
import BaseService from '../core/BaseService'
import PostService from '../util/PostService'

Expand Down
1 change: 1 addition & 0 deletions src/__tests__/validator.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ValidatorType } from '../core/Validator'
import { afterEach, beforeEach, describe, expect, it, test } from 'vitest'
import Validator from '../core/Validator'

describe('Validator', () => {
Expand Down
12 changes: 9 additions & 3 deletions src/core/BaseService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AxiosError, AxiosInstance, Method, AxiosRequestConfig, AxiosResponse } from 'axios'
import type { IParseOptions } from 'qs'
import { isObject } from 'lodash'
import qs from 'qs'
import { parse, stringify } from 'qs'
import Validator from './Validator'
import { hasFiles, objectToFormData } from '../util'

Expand Down Expand Up @@ -121,7 +121,13 @@ export default class BaseService {
}

private __getParameterString(url: string) {
const query = qs.stringify(this.parameters, { encode: false, skipNulls: true, addQueryPrefix: true })
const query = stringify(this.parameters, {
encode: true,
skipNulls: true,
addQueryPrefix: true,
encodeValuesOnly: true,
strictNullHandling: true,
})
return `${url}${query}`
}

Expand All @@ -139,7 +145,7 @@ export default class BaseService {
allowDots: true,
ignoreQueryPrefix: true,
})
const params = qs.parse(parameter, options)
const params = parse(parameter, options)
return this.setParameters(params)
}
this.parameters[parameter] = value
Expand Down
1 change: 0 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { defineConfig } from 'vite'

export default defineConfig({
test: {
globals: true,
deps: {
interopDefault: true,
},
Expand Down
Loading