Skip to content
This repository was archived by the owner on Sep 6, 2020. It is now read-only.

Commit 08c5398

Browse files
committed
去掉parse
1 parent f780deb commit 08c5398

File tree

3 files changed

+5
-33
lines changed

3 files changed

+5
-33
lines changed

src/utils.test.ts

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isEqual } from 'lodash';
2-
import { urlToList, isPromise, isUrl, getQuery, isBrowser, listToFlat } from './utils';
2+
import { urlToList, isPromise, isUrl, isBrowser, listToFlat } from './utils';
33

44
describe('util', () => {
55
describe('urlToList', () => {
@@ -52,20 +52,6 @@ describe('util', () => {
5252
});
5353
});
5454

55-
describe('getQuery', () => {
56-
it('empty', () => {
57-
expect(getQuery()).toEqual({});
58-
});
59-
60-
it('one', () => {
61-
expect(getQuery('id=1')).toEqual({ id: '1' });
62-
});
63-
64-
it('two arguments', () => {
65-
expect(getQuery('id=1&name=xxg')).toEqual({ id: '1', name: 'xxg' });
66-
});
67-
});
68-
6955
describe('isBrowser', () => {
7056
it('empty', () => {
7157
expect(isBrowser()).toBe(true);

src/utils.ts

-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { parse } from 'qs';
2-
31
import { reduce } from 'lodash';
42
import { IKeyValue } from './types';
53

@@ -40,18 +38,6 @@ export function isPromise(obj: any): boolean {
4038
*/
4139
export const isUrl = (path: string): boolean => reg.test(path);
4240

43-
/**
44-
* 解析url后的查询字符串并转化成object对象
45-
* @param data 要解析的字符串,没有则默认使用location.href
46-
*/
47-
export function getQuery(query?: string): { [key: string]: string } {
48-
let queryUrl = query || '';
49-
if (queryUrl.indexOf('?') !== -1) {
50-
[, queryUrl] = queryUrl.split('?');
51-
}
52-
return parse(queryUrl);
53-
}
54-
5541
/**
5642
* 将数组对象转换成object对象
5743
* @param items 要转换的数组

typings.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
declare module 'path-to-regexp' {
2-
function pathToRegexp(path: string): RegExp;
3-
export default pathToRegexp;
4-
}
1+
// declare module 'path-to-regexp' {
2+
// function pathToRegexp(path: string): RegExp;
3+
// export default pathToRegexp;
4+
// }

0 commit comments

Comments
 (0)