Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
consul
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
What's new
5
Snippets
Groups
Projects
gitlab-org
build
omnibus-mirror
consul
Commits
d319e8a5
Commit
d319e8a5
authored
4 years ago
by
John Cowen
Browse files
Options
Downloads
Patches
Plain Diff
Move route url decoding to our custom route class instead of reopening
parent
7bdce7e6
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ui-v2/app/initializers/route-urldecode-params.js
+0
-32
0 additions, 32 deletions
ui-v2/app/initializers/route-urldecode-params.js
ui-v2/app/routing/route.js
+33
-4
33 additions, 4 deletions
ui-v2/app/routing/route.js
with
33 additions
and
36 deletions
ui-v2/app/initializers/route-urldecode-params.js
deleted
100644 → 0
+
0
−
32
View file @
7bdce7e6
import
Route
from
'
@ember/routing/route
'
;
import
{
routes
}
from
'
consul-ui/router
'
;
import
wildcard
from
'
consul-ui/utils/routing/wildcard
'
;
const
isWildcard
=
wildcard
(
routes
);
/**
* This initializer adds urldecoding to the `params` passed into
* ember `model` hooks, plus of course anywhere else where `paramsFor`
* is used. This means the entire ember app is now changed so that all
* paramsFor calls returns urldecoded params instead of raw ones
*/
Route
.
reopen
({
paramsFor
:
function
()
{
const
params
=
this
.
_super
(...
arguments
);
if
(
isWildcard
(
this
.
routeName
))
{
return
Object
.
keys
(
params
).
reduce
(
function
(
prev
,
item
)
{
if
(
typeof
params
[
item
]
!==
'
undefined
'
)
{
prev
[
item
]
=
decodeURIComponent
(
params
[
item
]);
}
else
{
prev
[
item
]
=
params
[
item
];
}
return
prev
;
},
{});
}
else
{
return
params
;
}
},
});
export
function
initialize
()
{}
export
default
{
initialize
,
};
This diff is collapsed.
Click to expand it.
ui-v2/app/routing/route.js
+
33
−
4
View file @
d319e8a5
import
Route
from
'
@ember/routing/route
'
;
import
{
setProperties
}
from
'
@ember/object
'
;
/**
* Set the routeName for the controller so that it is
* available in the template for the route/controller
*/
// paramsFor
import
{
routes
}
from
'
consul-ui/router
'
;
import
wildcard
from
'
consul-ui/utils/routing/wildcard
'
;
const
isWildcard
=
wildcard
(
routes
);
export
default
class
BaseRoute
extends
Route
{
/**
* Set the routeName for the controller so that it is available in the template
* for the route/controller.. This is mainly used to give a route name to the
* Outlet component
*/
setupController
(
controller
,
model
)
{
setProperties
(
controller
,
{
routeName
:
this
.
routeName
,
});
super
.
setupController
(...
arguments
);
}
/**
* Adds urldecoding to any wildcard route `params` passed into ember `model`
* hooks, plus of course anywhere else where `paramsFor` is used. This means
* the entire ember app is now changed so that all paramsFor calls returns
* urldecoded params instead of raw ones.
* For example we use this largely for URLs for the KV store:
* /kv/*key > /ui/kv/%25-kv-name/%25-here > key = '%-kv-name/%-here'
*/
paramsFor
(
name
)
{
const
params
=
super
.
paramsFor
(...
arguments
);
if
(
isWildcard
(
this
.
routeName
))
{
return
Object
.
keys
(
params
).
reduce
(
function
(
prev
,
item
)
{
if
(
typeof
params
[
item
]
!==
'
undefined
'
)
{
prev
[
item
]
=
decodeURIComponent
(
params
[
item
]);
}
else
{
prev
[
item
]
=
params
[
item
];
}
return
prev
;
},
{});
}
else
{
return
params
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment