Skip to content
This repository was archived by the owner on May 26, 2023. It is now read-only.

Commit 23f4aef

Browse files
chore(tslint): member-ordering
1 parent fc9be91 commit 23f4aef

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

src/locationServices.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ export class Ng1LocationServices implements LocationConfig, LocationServices {
2626
// .onChange() registry
2727
private _urlListeners: Function[] = [];
2828

29+
/**
30+
* Applys ng1-specific path parameter encoding
31+
*
32+
* The Angular 1 `$___location` service is a bit weird.
33+
* It doesn't allow slashes to be encoded/decoded bi-directionally.
34+
*
35+
* See the writeup at https://github.com/angular-ui/ui-router/issues/2598
36+
*
37+
* This code patches the `path` parameter type so it encoded/decodes slashes as ~2F
38+
*
39+
* @param router
40+
*/
41+
static monkeyPatchPathParameterType(router: UIRouter) {
42+
let pathType: ParamType = router.urlMatcherFactory.type('path');
43+
44+
pathType.encode = (val: any) =>
45+
val != null ? val.toString().replace(/(~|\/)/g, m => ({ '~': '~~', '/': '~2F' }[m])) : val;
46+
47+
pathType.decode = (val: string) =>
48+
val != null ? val.toString().replace(/(~~|~2F)/g, m => ({ '~~': '~', '~2F': '/' }[m])) : val;
49+
50+
}
51+
2952
dispose() { }
3053

3154
constructor($locationProvider: ILocationProvider) {
@@ -68,27 +91,4 @@ export class Ng1LocationServices implements LocationConfig, LocationServices {
6891
// Bind these LocationConfig functions to $browser
6992
createProxyFunctions(_browser, this, _browser, ['baseHref']);
7093
}
71-
72-
/**
73-
* Applys ng1-specific path parameter encoding
74-
*
75-
* The Angular 1 `$___location` service is a bit weird.
76-
* It doesn't allow slashes to be encoded/decoded bi-directionally.
77-
*
78-
* See the writeup at https://github.com/angular-ui/ui-router/issues/2598
79-
*
80-
* This code patches the `path` parameter type so it encoded/decodes slashes as ~2F
81-
*
82-
* @param router
83-
*/
84-
static monkeyPatchPathParameterType(router: UIRouter) {
85-
let pathType: ParamType = router.urlMatcherFactory.type('path');
86-
87-
pathType.encode = (val: any) =>
88-
val != null ? val.toString().replace(/(~|\/)/g, m => ({ '~': '~~', '/': '~2F' }[m])) : val;
89-
90-
pathType.decode = (val: string) =>
91-
val != null ? val.toString().replace(/(~~|~2F)/g, m => ({ '~~': '~', '~2F': '/' }[m])) : val;
92-
93-
}
9494
}

src/urlRouterProvider.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export class UrlRouterProvider {
2727
/** @hidden */ _router: UIRouter;
2828
/** @hidden */ _urlRouter: UrlRouter;
2929

30+
static injectableHandler(router: UIRouter, handler): UrlRuleHandlerFn {
31+
return match =>
32+
services.$injector.invoke(handler, null, { $match: match, $stateParams: router.globals.params });
33+
}
34+
3035
/** @hidden */
3136
constructor(router: UIRouter) {
3237
this._router = router;
@@ -170,11 +175,6 @@ export class UrlRouterProvider {
170175
return this;
171176
};
172177

173-
static injectableHandler(router: UIRouter, handler): UrlRuleHandlerFn {
174-
return match =>
175-
services.$injector.invoke(handler, null, { $match: match, $stateParams: router.globals.params });
176-
}
177-
178178
/**
179179
* Disables monitoring of the URL.
180180
*

0 commit comments

Comments
 (0)