Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
0975f816
Commit
0975f816
authored
Jan 26, 2019
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated url query param encoding to exctly match angular encoding
parent
f3dc5381
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
public/app/core/specs/url.test.ts
+9
-0
public/app/core/utils/explore.ts
+1
-1
public/app/core/utils/url.ts
+12
-2
No files found.
public/app/core/specs/url.test.ts
View file @
0975f816
...
...
@@ -14,3 +14,12 @@ describe('toUrlParams', () => {
expect
(
url
).
toBe
(
'server=backend-01&hasSpace=has%20space&many=1&many=2&many=3&true&number=20&isNull=&isUndefined='
);
});
});
describe
(
'toUrlParams'
,
()
=>
{
it
(
'should encode the same way as angularjs'
,
()
=>
{
const
url
=
toUrlParams
({
server
:
':@'
,
});
expect
(
url
).
toBe
(
'server=:@'
);
});
});
public/app/core/utils/explore.ts
View file @
0975f816
...
...
@@ -84,7 +84,7 @@ export async function getExploreUrl(
}
const
exploreState
=
JSON
.
stringify
(
state
);
url
=
renderUrl
(
'/explore'
,
{
state
:
exploreState
});
url
=
renderUrl
(
'/explore'
,
{
left
:
exploreState
});
}
return
url
;
}
...
...
public/app/core/utils/url.ts
View file @
0975f816
...
...
@@ -11,6 +11,16 @@ export function renderUrl(path: string, query: UrlQueryMap | undefined): string
return
path
;
}
export
function
encodeURIComponentAsAngularJS
(
val
,
pctEncodeSpaces
)
{
return
encodeURIComponent
(
val
).
replace
(
/%40/gi
,
'@'
).
replace
(
/%3A/gi
,
':'
).
replace
(
/%24/g
,
'$'
).
replace
(
/%2C/gi
,
','
).
replace
(
/%3B/gi
,
';'
).
replace
(
/%20/g
,
(
pctEncodeSpaces
?
'%20'
:
'+'
));
}
export
function
toUrlParams
(
a
)
{
const
s
=
[];
const
rbracket
=
/
\[\]
$/
;
...
...
@@ -22,9 +32,9 @@ export function toUrlParams(a) {
const
add
=
(
k
,
v
)
=>
{
v
=
typeof
v
===
'function'
?
v
()
:
v
===
null
?
''
:
v
===
undefined
?
''
:
v
;
if
(
typeof
v
!==
'boolean'
)
{
s
[
s
.
length
]
=
encodeURIComponent
(
k
)
+
'='
+
encodeURIComponent
(
v
);
s
[
s
.
length
]
=
encodeURIComponent
AsAngularJS
(
k
,
true
)
+
'='
+
encodeURIComponentAsAngularJS
(
v
,
true
);
}
else
{
s
[
s
.
length
]
=
encodeURIComponent
(
k
);
s
[
s
.
length
]
=
encodeURIComponent
AsAngularJS
(
k
,
true
);
}
};
...
...
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