Skip to content

Commit 64510d0

Browse files
committed
fix: ✏️ remove not used function
1 parent 3286928 commit 64510d0

File tree

3 files changed

+6
-17
lines changed

3 files changed

+6
-17
lines changed

src/core/BaseService.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import type { IParseOptions } from 'qs'
44
import { isObject, isArray } from 'lodash'
55
import qs from 'qs'
66
import Validator from './Validator'
7-
import { hasFiles, objectToFormData, removeDoubleSlash } from '../util'
7+
import { hasFiles, objectToFormData } from '../util'
88

99
const validator = Validator
1010
const UNPROCESSABLE_ENTITY = 422
@@ -98,7 +98,7 @@ class BaseService {
9898
return new Promise<AxiosResponse<T>>((resolve, reject) => {
9999
const data = hasFiles(form) ? objectToFormData(form) : form
100100
const endpoint = param ? `/${this.endpoint}/${param}` : `/${this.endpoint}`
101-
const url = this.__getParameterString(removeDoubleSlash(endpoint))
101+
const url = this.__getParameterString(endpoint.replace(/\/\//g, '/'))
102102
config = Object.assign({}, config, { url, data, method })
103103
this.$http(config)
104104
.then((response) => {
@@ -166,9 +166,7 @@ class BaseService {
166166
}
167167

168168
beforeSubmit() {
169-
if (!this.$http) {
170-
throw new Error('Vue Axios Http, No http library provided.')
171-
}
169+
if (!this.$http) throw new Error('Vue Axios Http, No http library provided.')
172170
this.errors.flush()
173171
this.errors.processing = true
174172
this.errors.successful = false

src/core/Validator.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ class Validator {
1313
}
1414

1515
add(field: string, message: string, forceUpdate?: boolean) {
16-
if (this.missed(field)) {
17-
this.errors[field] = []
18-
}
19-
if (!this.errors[field].includes(message)) {
20-
this.errors[field].unshift(message)
21-
}
16+
if (this.missed(field)) this.errors[field] = []
17+
if (!this.errors[field].includes(message)) this.errors[field].unshift(message)
2218
if (forceUpdate) {
2319
this.errors[field] = []
2420
this.errors[field].push(message)
@@ -79,9 +75,7 @@ class Validator {
7975
}
8076
return errors
8177
}
82-
if (!fields.length) {
83-
return Object.keys(this.errors).length > 0
84-
}
78+
if (!fields.length) return Object.keys(this.errors).length > 0
8579
const errors: Record<string, any> = {}
8680
fields.forEach((key: string) => (errors[key] = this.get(key)))
8781
return Object.keys(errors).length > 0

src/util/string.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
export function removeDoubleSlash(url: string) {
2-
return url.replace(/\/\//g, '/')
3-
}
41
export const toCamelCase = (e: string) => {
52
return e.replace(/_([a-z])/g, (g) => g[1].toUpperCase())
63
}

0 commit comments

Comments
 (0)