Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
web-monitor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
web-monitor
Commits
b292e46f
Commit
b292e46f
authored
Jun 19, 2020
by
花裤衩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fixed param2Obj.spec.js
parent
4958db1b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
20 deletions
+13
-20
param2Obj.spec.js
tests/unit/utils/param2Obj.spec.js
+13
-20
No files found.
tests/unit/utils/param2Obj.spec.js
View file @
b292e46f
/**
* @param {string} url
* @returns {Object}
*/
export
function
param2Obj
(
url
)
{
const
search
=
decodeURIComponent
(
url
.
split
(
'?'
)[
1
]).
replace
(
/
\+
/g
,
' '
)
if
(
!
search
)
{
return
{}
}
const
obj
=
{}
const
searchArr
=
search
.
split
(
'&'
)
searchArr
.
forEach
(
v
=>
{
const
index
=
v
.
indexOf
(
'='
)
if
(
index
!==
-
1
)
{
const
name
=
v
.
substring
(
0
,
index
)
const
val
=
v
.
substring
(
index
+
1
,
v
.
length
)
obj
[
name
]
=
val
}
import
{
param2Obj
}
from
'@/utils/index.js'
describe
(
'Utils:param2Obj'
,
()
=>
{
const
url
=
'https://github.com/PanJiaChen/vue-element-admin?name=bill&age=29&sex=1&field=dGVzdA==&key=%E6%B5%8B%E8%AF%95'
it
(
'param2Obj test'
,
()
=>
{
expect
(
param2Obj
(
url
)).
toEqual
({
name
:
'bill'
,
age
:
'29'
,
sex
:
'1'
,
field
:
window
.
btoa
(
'test'
),
key
:
'测试'
})
})
return
obj
}
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment