@angular-wave/angular.ts 0.7.8 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/@types/core/parse/parse.d.ts +6 -7
  2. package/@types/directive/bind/bind.d.ts +2 -1
  3. package/@types/index.d.ts +1 -1
  4. package/@types/interface.d.ts +3 -1
  5. package/@types/{public.d.ts → ng.d.ts} +2 -2
  6. package/@types/router/globals.d.ts +1 -1
  7. package/@types/router/path/path-utils.d.ts +8 -11
  8. package/@types/router/state/interface.d.ts +1 -1
  9. package/@types/router/state/state-object.d.ts +1 -1
  10. package/@types/router/state/state-service.d.ts +8 -7
  11. package/@types/router/state-filters.d.ts +24 -2
  12. package/@types/router/transition/transition.d.ts +12 -15
  13. package/@types/router/url/url-matcher.d.ts +3 -3
  14. package/@types/router/url/url-rule.d.ts +1 -0
  15. package/@types/router/url/url-rules.d.ts +26 -6
  16. package/@types/router/url/url-service.d.ts +28 -38
  17. package/@types/services/http/http.d.ts +48 -1
  18. package/@types/services/http-backend/http-backend.d.ts +48 -35
  19. package/@types/services/location/interface.d.ts +55 -0
  20. package/@types/services/location/location.d.ts +225 -252
  21. package/@types/shared/common.d.ts +0 -2
  22. package/@types/shared/interface.d.ts +0 -4
  23. package/@types/{router/common → shared}/queue.d.ts +2 -2
  24. package/@types/shared/url-utils/interface.d.ts +0 -1
  25. package/@types/shared/url-utils/url-utils.d.ts +0 -5
  26. package/@types/shared/utils.d.ts +29 -6
  27. package/Makefile +6 -3
  28. package/dist/angular-ts.esm.js +960 -1062
  29. package/dist/angular-ts.umd.js +960 -1062
  30. package/dist/angular-ts.umd.min.js +1 -1
  31. package/docs/assets/scss/index.scss +23 -0
  32. package/docs/content/_index.md +9 -8
  33. package/docs/content/docs/_index.md +1 -1
  34. package/docs/content/docs/directive/app.md +1 -1
  35. package/docs/content/docs/directive/bind.md +1 -1
  36. package/docs/content/docs/directive/blur.md +1 -1
  37. package/docs/content/docs/directive/channel.md +2 -2
  38. package/docs/content/docs/directive/class-even.md +1 -1
  39. package/docs/content/docs/directive/class-odd.md +1 -1
  40. package/docs/content/docs/directive/class.md +1 -1
  41. package/docs/content/docs/directive/click.md +1 -1
  42. package/docs/content/docs/directive/copy.md +1 -1
  43. package/docs/content/docs/directive/cut.md +1 -1
  44. package/docs/content/docs/directive/dblclick.md +1 -1
  45. package/docs/content/docs/directive/focus.md +1 -1
  46. package/docs/content/docs/directive/get.md +3 -3
  47. package/docs/content/docs/directive/keydown.md +1 -1
  48. package/docs/content/docs/directive/keyup.md +1 -1
  49. package/docs/content/docs/directive/load.md +1 -1
  50. package/docs/content/docs/directive/mousedown.md +1 -1
  51. package/docs/content/docs/directive/mouseenter.md +1 -1
  52. package/docs/content/docs/directive/mouseleave.md +1 -1
  53. package/docs/content/docs/directive/mousemove.md +1 -1
  54. package/docs/content/docs/directive/mouseout.md +1 -1
  55. package/docs/content/docs/directive/mouseover.md +1 -1
  56. package/docs/content/docs/directive/mouseup.md +1 -1
  57. package/docs/content/docs/directive/non-bindable.md +28 -0
  58. package/docs/content/docs/provider/locationProvider.md +26 -0
  59. package/docs/content/docs/provider/templateCacheProvider.md +2 -2
  60. package/docs/content/docs/service/location.md +57 -0
  61. package/docs/content/docs/service/url.md +5 -0
  62. package/docs/layouts/partials/hooks/head-end.html +1 -1
  63. package/docs/layouts/shortcodes/version.html +1 -0
  64. package/docs/static/examples/counter/counter-test.html +0 -4
  65. package/docs/static/examples/eventbus/eventbus-test.html +0 -4
  66. package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +13 -0
  67. package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +3 -0
  68. package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +11 -0
  69. package/docs/static/typedoc/assets/highlight.css +6 -6
  70. package/docs/static/typedoc/assets/navigation.js +1 -1
  71. package/docs/static/typedoc/assets/search.js +1 -1
  72. package/docs/static/typedoc/classes/Location.html +55 -0
  73. package/docs/static/typedoc/classes/LocationProvider.html +20 -0
  74. package/docs/static/typedoc/index.html +1 -1
  75. package/docs/static/typedoc/interfaces/DefaultPorts.html +5 -0
  76. package/docs/static/typedoc/interfaces/Html5Mode.html +23 -0
  77. package/docs/static/typedoc/interfaces/Provider.html +2 -1
  78. package/docs/static/typedoc/interfaces/UrlParts.html +9 -0
  79. package/docs/static/typedoc/types/AnnotatedFactory.html +1 -1
  80. package/docs/static/typedoc/types/Expression.html +1 -1
  81. package/docs/static/typedoc/types/UrlChangeListener.html +5 -0
  82. package/docs/static/version.js +13 -0
  83. package/docs/test-results/.last-run.json +4 -0
  84. package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +50 -0
  85. package/package.json +1 -1
  86. package/src/{loader.js → angular.js} +1 -1
  87. package/src/angular.spec.js +189 -21
  88. package/src/animations/animate-css.js +17 -18
  89. package/src/animations/animate.spec.js +1 -1
  90. package/src/animations/shared.js +2 -3
  91. package/src/binding.spec.js +1 -1
  92. package/src/core/compile/compile.js +4 -7
  93. package/src/core/compile/compile.spec.js +1 -1
  94. package/src/core/controller/controller.spec.js +1 -1
  95. package/src/core/controller/controller.test.js +1 -0
  96. package/src/core/di/injector.js +7 -8
  97. package/src/core/di/injector.spec.js +2 -2
  98. package/src/core/di/injector.test.js +2 -2
  99. package/src/core/di/internal-injector.js +3 -6
  100. package/src/core/filter/filter.js +1 -1
  101. package/src/core/filter/filter.spec.js +1 -1
  102. package/src/core/filter/filter.test.js +1 -0
  103. package/src/core/interpolate/interpolate.js +4 -6
  104. package/src/core/interpolate/interpolate.spec.js +1 -1
  105. package/src/core/interpolate/interpolate.test.js +1 -0
  106. package/src/core/parse/ast/ast.spec.js +1 -1
  107. package/src/core/parse/ast/ast.test.js +1 -1
  108. package/src/core/parse/lexer/lexer.spec.js +1 -1
  109. package/src/core/parse/parse.js +150 -146
  110. package/src/core/parse/parse.spec.js +17 -16
  111. package/src/core/prop.spec.js +1 -1
  112. package/src/core/root-element.spec.js +1 -1
  113. package/src/core/scope/scope.js +10 -11
  114. package/src/core/scope/scope.spec.js +3 -4
  115. package/src/directive/aria/aria.spec.js +1 -1
  116. package/src/directive/aria/aria.test.js +1 -0
  117. package/src/directive/attrs/attrs.spec.js +1 -1
  118. package/src/directive/attrs/attrs.test.js +1 -0
  119. package/src/directive/attrs/boolean.spec.js +1 -1
  120. package/src/directive/attrs/boolean.test.js +1 -0
  121. package/src/directive/attrs/element-style.spec.js +1 -1
  122. package/src/directive/attrs/element-style.test.js +1 -0
  123. package/src/directive/attrs/src.spec.js +1 -1
  124. package/src/directive/attrs/src.test.js +1 -0
  125. package/src/directive/bind/bind-html.spec.js +1 -1
  126. package/src/directive/bind/bind.js +1 -0
  127. package/src/directive/bind/bind.spec.js +1 -1
  128. package/src/directive/bind/bind.test.js +1 -0
  129. package/src/directive/channel/channel.spec.js +1 -1
  130. package/src/directive/channel/channel.test.js +1 -0
  131. package/src/directive/class/class.spec.js +1 -1
  132. package/src/directive/class/class.test.js +1 -0
  133. package/src/directive/cloak/cloak.spec.js +1 -1
  134. package/src/directive/cloak/cloak.test.js +1 -0
  135. package/src/directive/controller/controller.spec.js +1 -1
  136. package/src/directive/controller/controller.test.js +1 -0
  137. package/src/directive/events/click.spec.js +1 -1
  138. package/src/directive/events/event.spec.js +1 -1
  139. package/src/directive/events/events.test.js +1 -0
  140. package/src/directive/form/form.js +8 -5
  141. package/src/directive/form/form.spec.js +1 -1
  142. package/src/directive/form/form.test.js +1 -0
  143. package/src/directive/http/delete.spec.js +1 -1
  144. package/src/directive/http/form-test.html +18 -0
  145. package/src/directive/http/get.spec.js +1 -1
  146. package/src/directive/http/http.js +12 -3
  147. package/src/directive/http/post.spec.js +504 -9
  148. package/src/directive/http/put.spec.js +1 -1
  149. package/src/directive/if/if.spec.js +1 -1
  150. package/src/directive/include/include.spec.js +1 -1
  151. package/src/directive/init/init.spec.js +1 -1
  152. package/src/directive/init/init.test.js +1 -0
  153. package/src/directive/input/input.js +13 -15
  154. package/src/directive/input/input.spec.js +1 -2
  155. package/src/directive/input/input.test.js +1 -0
  156. package/src/directive/messages/messages.spec.js +1 -1
  157. package/src/directive/messages/messages.test.js +1 -0
  158. package/src/directive/model/model.js +13 -13
  159. package/src/directive/model/model.spec.js +1 -1
  160. package/src/directive/model/model.test.js +1 -0
  161. package/src/directive/model-options/model-option.test.js +1 -0
  162. package/src/directive/model-options/model-options.js +1 -1
  163. package/src/directive/model-options/model-options.spec.js +1 -1
  164. package/src/directive/non-bindable/non-bindable.spec.js +1 -1
  165. package/src/directive/non-bindable/non-bindable.test.js +1 -0
  166. package/src/directive/observe/observe.spec.js +1 -1
  167. package/src/directive/observe/observe.test.js +1 -0
  168. package/src/directive/on/on.spec.js +1 -1
  169. package/src/directive/on/on.test.js +1 -0
  170. package/src/directive/options/options.spec.js +1 -1
  171. package/src/directive/options/options.test.js +1 -0
  172. package/src/directive/ref/href.spec.js +1 -1
  173. package/src/directive/ref/href.test.js +2 -0
  174. package/src/directive/ref/ref.spec.js +1 -1
  175. package/src/directive/repeat/repeat.spec.js +2 -3
  176. package/src/directive/repeat/repeat.test.js +1 -0
  177. package/src/directive/script/script.spec.js +1 -1
  178. package/src/directive/script/script.test.js +1 -0
  179. package/src/directive/select/select.js +1 -1
  180. package/src/directive/select/select.spec.js +1 -1
  181. package/src/directive/select/select.test.js +1 -0
  182. package/src/directive/setter/setter.spec.js +1 -1
  183. package/src/directive/setter/setter.test.js +1 -0
  184. package/src/directive/show-hide/show-hide.spec.js +1 -1
  185. package/src/directive/show-hide/show-hide.test.js +1 -0
  186. package/src/directive/style/style.spec.js +1 -1
  187. package/src/directive/style/style.test.js +1 -0
  188. package/src/directive/switch/switch.spec.js +1 -1
  189. package/src/directive/switch/switch.test.js +1 -0
  190. package/src/directive/validators/validators.js +82 -84
  191. package/src/directive/validators/validators.spec.js +5 -4
  192. package/src/directive/validators/validators.test.js +1 -0
  193. package/src/filters/filter.spec.js +1 -1
  194. package/src/filters/filters.spec.js +1 -1
  195. package/src/filters/limit-to.js +2 -3
  196. package/src/filters/limit-to.spec.js +1 -1
  197. package/src/filters/order-by.spec.js +1 -1
  198. package/src/index.js +1 -1
  199. package/src/injection-tokens.js +5 -1
  200. package/src/interface.ts +3 -1
  201. package/src/loader.md +0 -155
  202. package/src/{public.js → ng.js} +7 -8
  203. package/src/{public.spec.js → ng.spec.js} +1 -1
  204. package/src/router/directives/state-directives.spec.js +8 -7
  205. package/src/router/directives/view-directive.js +2 -8
  206. package/src/router/directives/view-directive.spec.js +8 -9
  207. package/src/router/{common/common.html → glob/glob.html} +2 -3
  208. package/src/router/{common/common.test.js → glob/glob.test.js} +2 -1
  209. package/src/router/globals.js +1 -1
  210. package/src/router/path/path-utils.js +5 -0
  211. package/src/router/router-test-hashbang.html +45 -0
  212. package/src/router/services.spec.js +5 -6
  213. package/src/router/state/interface.ts +1 -1
  214. package/src/router/state/state-builder.js +3 -3
  215. package/src/router/state/state-builder.spec.js +1 -1
  216. package/src/router/state/state-object.js +1 -1
  217. package/src/router/state/state-registry.js +2 -2
  218. package/src/router/state/state-service.js +13 -10
  219. package/src/router/state/state.spec.js +23 -22
  220. package/src/router/state/state.test.js +1 -0
  221. package/src/router/state/views.js +1 -1
  222. package/src/router/state-filter.spec.js +1 -1
  223. package/src/router/state-filters.js +13 -9
  224. package/src/router/template-factory.js +5 -4
  225. package/src/router/template-factory.spec.js +1 -1
  226. package/src/router/transition/hook-registry.js +1 -1
  227. package/src/router/transition/transition-service.js +6 -5
  228. package/src/router/transition/transition.js +4 -4
  229. package/src/router/url/url-matcher.js +3 -3
  230. package/src/router/url/url-rule.js +1 -0
  231. package/src/router/url/url-rules.js +8 -5
  232. package/src/router/url/url-service.js +77 -76
  233. package/src/router/url/url-service.spec.js +55 -39
  234. package/src/router/url/url.test.js +1 -0
  235. package/src/router/view/view.js +4 -5
  236. package/src/router/view/view.spec.js +10 -12
  237. package/src/router/view/view.test.js +1 -0
  238. package/src/router/view-hook.spec.js +1 -1
  239. package/src/router/view-scroll.spec.js +1 -1
  240. package/src/services/anchor-scroll.html +2 -2
  241. package/src/services/anchor-scroll.js +5 -4
  242. package/src/services/http/http.js +9 -4
  243. package/src/services/http/http.spec.js +2 -7
  244. package/src/services/http/template-request.spec.js +1 -1
  245. package/src/services/http-backend/http-backend.js +51 -77
  246. package/src/services/http-backend/http-backend.spec.js +1 -2
  247. package/src/services/http-backend/http-backend.test.js +1 -0
  248. package/src/services/location/interface.ts +62 -0
  249. package/src/services/location/location.js +433 -520
  250. package/src/services/location/location.spec.js +909 -530
  251. package/src/services/location/location.test.js +2 -2
  252. package/src/services/log/log.spec.js +1 -1
  253. package/src/services/log/log.test.js +1 -0
  254. package/src/services/pubsub/pubsub.spec.js +1 -1
  255. package/src/services/sce/sce.js +5 -7
  256. package/src/services/sce/sce.md +2 -2
  257. package/src/services/sce/sce.spec.js +1 -1
  258. package/src/services/template-cache/template-cache.spec.js +1 -1
  259. package/src/services/template-cache/template-cache.test.js +1 -0
  260. package/src/shared/common.js +0 -5
  261. package/src/shared/common.spec.js +1 -1
  262. package/src/shared/interface.ts +0 -4
  263. package/src/{router/common → shared}/queue.js +7 -7
  264. package/src/shared/shared.html +1 -0
  265. package/src/shared/shared.test.js +1 -0
  266. package/src/shared/url-utils/interface.ts +0 -2
  267. package/src/shared/url-utils/url-utils.js +6 -30
  268. package/src/shared/url-utils/url-utils.spec.js +10 -9
  269. package/src/shared/utils.js +32 -9
  270. package/src/shared/utils.spec.js +35 -1
  271. package/src/src.html +1 -2
  272. package/typedoc.json +0 -1
  273. package/utils/express.js +27 -1
  274. package/utils/version.cjs +23 -0
  275. package/@types/router/state-provider.d.ts +0 -123
  276. package/src/directive/non-bindable/non-bindable.md +0 -17
  277. package/src/loader.spec.js +0 -169
  278. package/src/router/state-provider.js +0 -146
  279. package/src/services/location/location.md +0 -114
  280. package/src/shared/url-utils/url-utils.md +0 -46
  281. /package/@types/{loader.d.ts → angular.d.ts} +0 -0
  282. /package/@types/router/{common → glob}/glob.d.ts +0 -0
  283. /package/src/router/{common → glob}/glob.js +0 -0
  284. /package/src/router/{common → glob}/glob.spec.js +0 -0
  285. /package/src/{router/common → shared}/queue.spec.js +0 -0
@@ -1,9 +1,17 @@
1
1
  import {
2
- LocationHtml5Url,
3
- LocationHashbangUrl,
2
+ decodePath,
3
+ encodePath,
4
+ normalizePath,
5
+ Location,
4
6
  LocationProvider,
7
+ parseAppUrl,
8
+ stripBaseUrl,
9
+ stripHash,
10
+ stripFile,
11
+ serverBase,
12
+ urlsEqual,
5
13
  } from "./location.js";
6
- import { Angular } from "../../loader.js";
14
+ import { Angular } from "../../angular.js";
7
15
  import { createInjector } from "../../core/di/injector.js";
8
16
 
9
17
  describe("$location", () => {
@@ -24,12 +32,14 @@ describe("$location", () => {
24
32
  describe("defaults", () => {
25
33
  it('should have hashPrefix of "!"', () => {
26
34
  let provider = new LocationProvider();
27
- expect(provider.getHashPrefix()).toBe("!");
35
+ expect(provider.hashPrefixConf).toBe("!");
28
36
  });
29
37
 
30
- it("should not be html5 mode", () => {
38
+ it("should default to html5 mode with no base and rewrite links", () => {
31
39
  let provider = new LocationProvider();
32
- expect(provider.getHtml5Mode().enabled).toBeFalse();
40
+ expect(provider.html5ModeConf.enabled).toBeTrue();
41
+ expect(provider.html5ModeConf.requireBase).toBeFalse();
42
+ expect(provider.html5ModeConf.rewriteLinks).toBeTrue();
33
43
  });
34
44
  });
35
45
 
@@ -61,35 +71,28 @@ describe("$location", () => {
61
71
 
62
72
  it("should not include the drive name in path() on WIN", () => {
63
73
  // See issue #4680 for details
64
- const locationUrl = new LocationHashbangUrl(
65
- "file:///base",
66
- "file:///",
67
- "#!",
68
- );
69
- locationUrl.$$parse("file:///base#!/foo?a=b&c#hash");
74
+ const locationUrl = new Location("file:///base", "file:///", false, "#!");
75
+ locationUrl.parse("file:///base#!/foo?a=b&c#hash");
70
76
 
71
- expect(locationUrl.path()).toBe("/foo");
77
+ expect(locationUrl.getPath()).toBe("/foo");
72
78
  });
73
79
 
74
80
  it("should include the drive name if it was provided in the input url", () => {
75
- const locationUrl = new LocationHashbangUrl(
76
- "file:///base",
77
- "file:///",
78
- "#!",
79
- );
80
- locationUrl.$$parse("file:///base#!/C:/foo?a=b&c#hash");
81
+ const locationUrl = new Location("file:///base", "file:///", false, "#!");
82
+ locationUrl.parse("file:///base#!/C:/foo?a=b&c#hash");
81
83
 
82
- expect(locationUrl.path()).toBe("/C:/foo");
84
+ expect(locationUrl.getPath()).toBe("/C:/foo");
83
85
  });
84
86
  });
85
87
 
86
88
  describe("NewUrl", () => {
87
89
  function createLocationHtml5Url() {
88
- const locationUrl = new LocationHtml5Url(
90
+ const locationUrl = new Location(
89
91
  "http://www.domain.com:9877/",
90
92
  "http://www.domain.com:9877/",
93
+ true,
91
94
  );
92
- locationUrl.$$parse(
95
+ locationUrl.parse(
93
96
  "http://www.domain.com:9877/path/b?search=a&b=c&d#hash",
94
97
  );
95
98
  return locationUrl;
@@ -97,67 +100,64 @@ describe("$location", () => {
97
100
 
98
101
  it("should provide common getters", () => {
99
102
  const locationUrl = createLocationHtml5Url();
100
- expect(locationUrl.absUrl()).toBe(
103
+ expect(locationUrl.absUrl).toBe(
101
104
  "http://www.domain.com:9877/path/b?search=a&b=c&d#hash",
102
105
  );
103
- expect(locationUrl.protocol()).toBe("http");
104
- expect(locationUrl.host()).toBe("www.domain.com");
105
- expect(locationUrl.port()).toBe(9877);
106
- expect(locationUrl.path()).toBe("/path/b");
107
- expect(locationUrl.search()).toEqual({ search: "a", b: "c", d: true });
108
- expect(locationUrl.hash()).toBe("hash");
109
- expect(locationUrl.url()).toBe("/path/b?search=a&b=c&d#hash");
106
+ expect(locationUrl.getPath()).toBe("/path/b");
107
+ expect(locationUrl.getSearch()).toEqual({ search: "a", b: "c", d: true });
108
+ expect(locationUrl.getHash()).toBe("hash");
109
+ expect(locationUrl.getUrl()).toBe("/path/b?search=a&b=c&d#hash");
110
110
  });
111
111
 
112
112
  it("path() should change path", () => {
113
113
  const locationUrl = createLocationHtml5Url();
114
- locationUrl.path("/new/path");
115
- expect(locationUrl.path()).toBe("/new/path");
116
- expect(locationUrl.absUrl()).toBe(
114
+ locationUrl.setPath("/new/path");
115
+ expect(locationUrl.getPath()).toBe("/new/path");
116
+ expect(locationUrl.absUrl).toBe(
117
117
  "http://www.domain.com:9877/new/path?search=a&b=c&d#hash",
118
118
  );
119
119
  });
120
120
 
121
121
  it("path() should not break on numeric values", () => {
122
122
  const locationUrl = createLocationHtml5Url();
123
- locationUrl.path(1);
124
- expect(locationUrl.path()).toBe("/1");
125
- expect(locationUrl.absUrl()).toBe(
123
+ locationUrl.setPath(1);
124
+ expect(locationUrl.getPath()).toBe("/1");
125
+ expect(locationUrl.absUrl).toBe(
126
126
  "http://www.domain.com:9877/1?search=a&b=c&d#hash",
127
127
  );
128
128
  });
129
129
 
130
130
  it("path() should allow using 0 as path", () => {
131
131
  const locationUrl = createLocationHtml5Url();
132
- locationUrl.path(0);
133
- expect(locationUrl.path()).toBe("/0");
134
- expect(locationUrl.absUrl()).toBe(
132
+ locationUrl.setPath(0);
133
+ expect(locationUrl.getPath()).toBe("/0");
134
+ expect(locationUrl.absUrl).toBe(
135
135
  "http://www.domain.com:9877/0?search=a&b=c&d#hash",
136
136
  );
137
137
  });
138
138
 
139
139
  it("path() should set to empty path on null value", () => {
140
140
  const locationUrl = createLocationHtml5Url();
141
- locationUrl.path("/foo");
142
- expect(locationUrl.path()).toBe("/foo");
143
- locationUrl.path(null);
144
- expect(locationUrl.path()).toBe("/");
141
+ locationUrl.setPath("/foo");
142
+ expect(locationUrl.getPath()).toBe("/foo");
143
+ locationUrl.setPath(null);
144
+ expect(locationUrl.getPath()).toBe("/");
145
145
  });
146
146
 
147
147
  it("search() should accept string", () => {
148
148
  const locationUrl = createLocationHtml5Url();
149
- locationUrl.search("x=y&c");
150
- expect(locationUrl.search()).toEqual({ x: "y", c: true });
151
- expect(locationUrl.absUrl()).toBe(
149
+ locationUrl.setSearch("x=y&c");
150
+ expect(locationUrl.getSearch()).toEqual({ x: "y", c: true });
151
+ expect(locationUrl.absUrl).toBe(
152
152
  "http://www.domain.com:9877/path/b?x=y&c#hash",
153
153
  );
154
154
  });
155
155
 
156
156
  it("search() should accept object", () => {
157
157
  const locationUrl = createLocationHtml5Url();
158
- locationUrl.search({ one: 1, two: true });
159
- expect(locationUrl.search()).toEqual({ one: 1, two: true });
160
- expect(locationUrl.absUrl()).toBe(
158
+ locationUrl.setSearch({ one: 1, two: true });
159
+ expect(locationUrl.getSearch()).toEqual({ one: 1, two: true });
160
+ expect(locationUrl.absUrl).toBe(
161
161
  "http://www.domain.com:9877/path/b?one=1&two#hash",
162
162
  );
163
163
  });
@@ -165,270 +165,258 @@ describe("$location", () => {
165
165
  it("search() should copy object", () => {
166
166
  const locationUrl = createLocationHtml5Url();
167
167
  const obj = { one: 1, two: true, three: null };
168
- locationUrl.search(obj);
168
+ locationUrl.setSearch(obj);
169
169
  expect(obj).toEqual({ one: 1, two: true, three: null });
170
170
  obj.one = "changed";
171
- expect(locationUrl.search()).toEqual({ one: 1, two: true });
172
- expect(locationUrl.absUrl()).toBe(
171
+ expect(locationUrl.getSearch()).toEqual({ one: 1, two: true });
172
+ expect(locationUrl.absUrl).toBe(
173
173
  "http://www.domain.com:9877/path/b?one=1&two#hash",
174
174
  );
175
175
  });
176
176
 
177
177
  it("search() should change single parameter", () => {
178
178
  const locationUrl = createLocationHtml5Url();
179
- locationUrl.search({ id: "old", preserved: true });
180
- locationUrl.search("id", "new");
179
+ locationUrl.setSearch({ id: "old", preserved: true });
180
+ locationUrl.setSearch("id", "new");
181
181
 
182
- expect(locationUrl.search()).toEqual({ id: "new", preserved: true });
182
+ expect(locationUrl.getSearch()).toEqual({ id: "new", preserved: true });
183
183
  });
184
184
 
185
185
  it("search() should remove single parameter", () => {
186
186
  const locationUrl = createLocationHtml5Url();
187
- locationUrl.search({ id: "old", preserved: true });
188
- locationUrl.search("id", null);
187
+ locationUrl.setSearch({ id: "old", preserved: true });
188
+ locationUrl.setSearch("id", null);
189
189
 
190
- expect(locationUrl.search()).toEqual({ preserved: true });
190
+ expect(locationUrl.getSearch()).toEqual({ preserved: true });
191
191
  });
192
192
 
193
193
  it("search() should remove multiple parameters", () => {
194
194
  const locationUrl = createLocationHtml5Url();
195
- locationUrl.search({ one: 1, two: true });
196
- expect(locationUrl.search()).toEqual({ one: 1, two: true });
197
- locationUrl.search({ one: null, two: null });
198
- expect(locationUrl.search()).toEqual({});
199
- expect(locationUrl.absUrl()).toBe(
200
- "http://www.domain.com:9877/path/b#hash",
201
- );
195
+ locationUrl.setSearch({ one: 1, two: true });
196
+ expect(locationUrl.getSearch()).toEqual({ one: 1, two: true });
197
+ locationUrl.setSearch({ one: null, two: null });
198
+ expect(locationUrl.getSearch()).toEqual({});
199
+ expect(locationUrl.absUrl).toBe("http://www.domain.com:9877/path/b#hash");
202
200
  });
203
201
 
204
202
  it("search() should accept numeric keys", () => {
205
203
  const locationUrl = createLocationHtml5Url();
206
- locationUrl.search({ 1: "one", 2: "two" });
207
- expect(locationUrl.search()).toEqual({ 1: "one", 2: "two" });
208
- expect(locationUrl.absUrl()).toBe(
204
+ locationUrl.setSearch({ 1: "one", 2: "two" });
205
+ expect(locationUrl.getSearch()).toEqual({ 1: "one", 2: "two" });
206
+ expect(locationUrl.absUrl).toBe(
209
207
  "http://www.domain.com:9877/path/b?1=one&2=two#hash",
210
208
  );
211
209
  });
212
210
 
213
211
  it("search() should handle multiple value", () => {
214
212
  const locationUrl = createLocationHtml5Url();
215
- locationUrl.search("a&b");
216
- expect(locationUrl.search()).toEqual({ a: true, b: true });
213
+ locationUrl.setSearch("a&b");
214
+ expect(locationUrl.getSearch()).toEqual({ a: true, b: true });
217
215
 
218
- locationUrl.search("a", null);
216
+ locationUrl.setSearch("a", null);
219
217
 
220
- expect(locationUrl.search()).toEqual({ b: true });
218
+ expect(locationUrl.getSearch()).toEqual({ b: true });
221
219
 
222
- locationUrl.search("b", undefined);
223
- expect(locationUrl.search()).toEqual({});
220
+ locationUrl.setSearch("b", undefined);
221
+ expect(locationUrl.getSearch()).toEqual({});
224
222
  });
225
223
 
226
224
  it("search() should handle single value", () => {
227
225
  const locationUrl = createLocationHtml5Url();
228
- locationUrl.search("ignore");
229
- expect(locationUrl.search()).toEqual({ ignore: true });
230
- locationUrl.search(1);
231
- expect(locationUrl.search()).toEqual({ 1: true });
226
+ locationUrl.setSearch("ignore");
227
+ expect(locationUrl.getSearch()).toEqual({ ignore: true });
228
+ locationUrl.setSearch(1);
229
+ expect(locationUrl.getSearch()).toEqual({ 1: true });
232
230
  });
233
231
 
234
232
  it("search() should throw error an incorrect argument", () => {
235
233
  const locationUrl = createLocationHtml5Url();
236
234
  expect(() => {
237
- locationUrl.search(null);
235
+ locationUrl.setSearch(null);
238
236
  }).toThrowError(/isrcharg/);
239
237
  expect(() => {
240
- locationUrl.search(undefined);
238
+ locationUrl.setSearch(undefined);
241
239
  }).toThrowError(/isrcharg/);
242
240
  });
243
241
 
244
242
  it("hash() should change hash fragment", () => {
245
243
  const locationUrl = createLocationHtml5Url();
246
- locationUrl.hash("new-hash");
247
- expect(locationUrl.hash()).toBe("new-hash");
248
- expect(locationUrl.absUrl()).toBe(
244
+ locationUrl.setHash("new-hash");
245
+ expect(locationUrl.getHash()).toBe("new-hash");
246
+ expect(locationUrl.absUrl).toBe(
249
247
  "http://www.domain.com:9877/path/b?search=a&b=c&d#new-hash",
250
248
  );
251
249
  });
252
250
 
253
251
  it("hash() should accept numeric parameter", () => {
254
252
  const locationUrl = createLocationHtml5Url();
255
- locationUrl.hash(5);
256
- expect(locationUrl.hash()).toBe("5");
257
- expect(locationUrl.absUrl()).toBe(
253
+ locationUrl.setHash(5);
254
+ expect(locationUrl.getHash()).toBe("5");
255
+ expect(locationUrl.absUrl).toBe(
258
256
  "http://www.domain.com:9877/path/b?search=a&b=c&d#5",
259
257
  );
260
258
  });
261
259
 
262
260
  it("hash() should allow using 0", () => {
263
261
  const locationUrl = createLocationHtml5Url();
264
- locationUrl.hash(0);
265
- expect(locationUrl.hash()).toBe("0");
266
- expect(locationUrl.absUrl()).toBe(
262
+ locationUrl.setHash(0);
263
+ expect(locationUrl.getHash()).toBe("0");
264
+ expect(locationUrl.absUrl).toBe(
267
265
  "http://www.domain.com:9877/path/b?search=a&b=c&d#0",
268
266
  );
269
267
  });
270
268
 
271
269
  it("hash() should accept null parameter", () => {
272
270
  const locationUrl = createLocationHtml5Url();
273
- locationUrl.hash(null);
274
- expect(locationUrl.hash()).toBe("");
275
- expect(locationUrl.absUrl()).toBe(
271
+ locationUrl.setHash(null);
272
+ expect(locationUrl.getHash()).toBe("");
273
+ expect(locationUrl.absUrl).toBe(
276
274
  "http://www.domain.com:9877/path/b?search=a&b=c&d",
277
275
  );
278
276
  });
279
277
 
280
- it("url() should change the path, search and hash", () => {
278
+ it("url getter/setter should change the path, search and hash", () => {
281
279
  const locationUrl = createLocationHtml5Url();
282
- locationUrl.url("/some/path?a=b&c=d#hhh");
283
- expect(locationUrl.url()).toBe("/some/path?a=b&c=d#hhh");
284
- expect(locationUrl.absUrl()).toBe(
280
+ locationUrl.setUrl("/some/path?a=b&c=d#hhh");
281
+ expect(locationUrl.getUrl()).toBe("/some/path?a=b&c=d#hhh");
282
+ expect(locationUrl.absUrl).toBe(
285
283
  "http://www.domain.com:9877/some/path?a=b&c=d#hhh",
286
284
  );
287
- expect(locationUrl.path()).toBe("/some/path");
288
- expect(locationUrl.search()).toEqual({ a: "b", c: "d" });
289
- expect(locationUrl.hash()).toBe("hhh");
285
+ expect(locationUrl.getPath()).toBe("/some/path");
286
+ expect(locationUrl.getSearch()).toEqual({ a: "b", c: "d" });
287
+ expect(locationUrl.getHash()).toBe("hhh");
290
288
  });
291
289
 
292
- it("url() should change only hash when no search and path specified", () => {
290
+ it("url getter/setter should change only hash when no search and path specified", () => {
293
291
  const locationUrl = createLocationHtml5Url();
294
- locationUrl.url("#some-hash");
292
+ locationUrl.setUrl("#some-hash");
295
293
 
296
- expect(locationUrl.hash()).toBe("some-hash");
297
- expect(locationUrl.url()).toBe("/path/b?search=a&b=c&d#some-hash");
298
- expect(locationUrl.absUrl()).toBe(
294
+ expect(locationUrl.getHash()).toBe("some-hash");
295
+ expect(locationUrl.getUrl()).toBe("/path/b?search=a&b=c&d#some-hash");
296
+ expect(locationUrl.absUrl).toBe(
299
297
  "http://www.domain.com:9877/path/b?search=a&b=c&d#some-hash",
300
298
  );
301
299
  });
302
300
 
303
- it("url() should change only search and hash when no path specified", () => {
301
+ it("setUrl() should change only search and hash when no path specified", () => {
304
302
  const locationUrl = createLocationHtml5Url();
305
- locationUrl.url("?a=b");
303
+ locationUrl.setUrl("?a=b");
306
304
 
307
- expect(locationUrl.search()).toEqual({ a: "b" });
308
- expect(locationUrl.hash()).toBe("");
309
- expect(locationUrl.path()).toBe("/path/b");
305
+ expect(locationUrl.getSearch()).toEqual({ a: "b" });
306
+ expect(locationUrl.getHash()).toBe("");
307
+ expect(locationUrl.getPath()).toBe("/path/b");
310
308
  });
311
309
 
312
- it("url() should reset search and hash when only path specified", () => {
310
+ it("setUrl() should reset search and hash when only path specified", () => {
313
311
  const locationUrl = createLocationHtml5Url();
314
- locationUrl.url("/new/path");
312
+ locationUrl.setUrl("/new/path");
315
313
 
316
- expect(locationUrl.path()).toBe("/new/path");
317
- expect(locationUrl.search()).toEqual({});
318
- expect(locationUrl.hash()).toBe("");
314
+ expect(locationUrl.getPath()).toBe("/new/path");
315
+ expect(locationUrl.getSearch()).toEqual({});
316
+ expect(locationUrl.getHash()).toBe("");
319
317
  });
320
318
 
321
- it("url() should change path when empty string specified", () => {
319
+ it("setUrl() should change path when empty string specified", () => {
322
320
  const locationUrl = createLocationHtml5Url();
323
- locationUrl.url("");
321
+ locationUrl.setUrl("");
324
322
 
325
- expect(locationUrl.path()).toBe("/");
326
- expect(locationUrl.search()).toEqual({});
327
- expect(locationUrl.hash()).toBe("");
328
- });
329
-
330
- it("replace should set $$replace flag and return itself", () => {
331
- const locationUrl = createLocationHtml5Url();
332
- expect(locationUrl.$$replace).toBe(false);
333
-
334
- locationUrl.replace();
335
- expect(locationUrl.$$replace).toBe(true);
336
- expect(locationUrl.replace()).toBe(locationUrl);
323
+ expect(locationUrl.getPath()).toBe("/");
324
+ expect(locationUrl.getSearch()).toEqual({});
325
+ expect(locationUrl.getHash()).toBe("");
337
326
  });
338
327
 
339
328
  it("should parse new url", () => {
340
- let locationUrl = new LocationHtml5Url(
341
- "http://host.com/",
342
- "http://host.com/",
343
- );
344
- locationUrl.$$parse("http://host.com/base");
345
- expect(locationUrl.path()).toBe("/base");
329
+ let locationUrl = new Location("http://host.com/", "http://host.com/");
330
+ locationUrl.parse("http://host.com/base");
331
+ expect(locationUrl.getPath()).toBe("/base");
346
332
 
347
- locationUrl = new LocationHtml5Url(
348
- "http://host.com/",
349
- "http://host.com/",
350
- );
351
- locationUrl.$$parse("http://host.com/base#");
352
- expect(locationUrl.path()).toBe("/base");
333
+ locationUrl = new Location("http://host.com/", "http://host.com/", true);
334
+ locationUrl.parse("http://host.com/base#");
335
+ expect(locationUrl.getPath()).toBe("/base");
353
336
  });
354
337
 
355
338
  it("should prefix path with forward-slash", () => {
356
- const locationUrl = new LocationHtml5Url(
339
+ const locationUrl = new Location(
357
340
  "http://server/",
358
341
  "http://server/",
342
+ true,
359
343
  );
360
- locationUrl.path("b");
344
+ locationUrl.setPath("b");
361
345
 
362
- expect(locationUrl.path()).toBe("/b");
363
- expect(locationUrl.absUrl()).toBe("http://server/b");
346
+ expect(locationUrl.getPath()).toBe("/b");
347
+ expect(locationUrl.absUrl).toBe("http://server/b");
364
348
  });
365
349
 
366
350
  it("should set path to forward-slash when empty", () => {
367
- const locationUrl = new LocationHtml5Url(
351
+ const locationUrl = new Location(
368
352
  "http://server/",
369
353
  "http://server/",
354
+ true,
370
355
  );
371
- locationUrl.$$parse("http://server/");
372
- expect(locationUrl.path()).toBe("/");
373
- expect(locationUrl.absUrl()).toBe("http://server/");
356
+ locationUrl.parse("http://server/");
357
+ expect(locationUrl.getPath()).toBe("/");
358
+ expect(locationUrl.absUrl).toBe("http://server/");
374
359
  });
375
360
 
376
361
  it("setters should return Url object to allow chaining", () => {
377
362
  const locationUrl = createLocationHtml5Url();
378
- expect(locationUrl.path("/any")).toBe(locationUrl);
379
- expect(locationUrl.search("")).toBe(locationUrl);
380
- expect(locationUrl.hash("aaa")).toBe(locationUrl);
381
- expect(locationUrl.url("/some")).toBe(locationUrl);
363
+ expect(locationUrl.setPath("/any")).toBe(locationUrl);
364
+ expect(locationUrl.setSearch("")).toBe(locationUrl);
365
+ expect(locationUrl.setHash("aaa")).toBe(locationUrl);
366
+ expect(locationUrl.setUrl("/some")).toBe(locationUrl);
382
367
  });
383
368
 
384
369
  it("should not preserve old properties when parsing new url", () => {
385
370
  const locationUrl = createLocationHtml5Url();
386
- locationUrl.$$parse("http://www.domain.com:9877/a");
371
+ locationUrl.parse("http://www.domain.com:9877/a");
387
372
 
388
- expect(locationUrl.path()).toBe("/a");
389
- expect(locationUrl.search()).toEqual({});
390
- expect(locationUrl.hash()).toBe("");
391
- expect(locationUrl.absUrl()).toBe("http://www.domain.com:9877/a");
373
+ expect(locationUrl.getPath()).toBe("/a");
374
+ expect(locationUrl.getSearch()).toEqual({});
375
+ expect(locationUrl.getHash()).toBe("");
376
+ expect(locationUrl.absUrl).toBe("http://www.domain.com:9877/a");
392
377
  });
393
378
 
394
379
  // it("should not rewrite when hashbang url is not given", () => {
395
380
  // initService({ html5Mode: true, hashPrefix: "!", supportHistory: true });
396
381
  // initBrowser({ url: "http://domain.com/base/a/b", basePath: "/base" });
397
- // expect($browser.url()).toBe("http://domain.com/base/a/b");
382
+ // expect($browser.getUrl()).toBe("http://domain.com/base/a/b");
398
383
  // });
399
384
 
400
385
  it("should prepend path with basePath", () => {
401
- const locationUrl = new LocationHtml5Url(
386
+ const locationUrl = new Location(
402
387
  "http://server/base/",
403
388
  "http://server/base/",
389
+ true,
404
390
  );
405
- locationUrl.$$parse("http://server/base/abc?a");
406
- expect(locationUrl.path()).toBe("/abc");
407
- expect(locationUrl.search()).toEqual({ a: true });
391
+ locationUrl.parse("http://server/base/abc?a");
392
+ expect(locationUrl.getPath()).toBe("/abc");
393
+ expect(locationUrl.getSearch()).toEqual({ a: true });
408
394
 
409
- locationUrl.path("/new/path");
410
- expect(locationUrl.absUrl()).toBe("http://server/base/new/path?a");
395
+ locationUrl.setPath("/new/path");
396
+ expect(locationUrl.absUrl).toBe("http://server/base/new/path?a");
411
397
  });
412
398
 
413
399
  it("should throw error when invalid server url given", () => {
414
- const locationUrl = new LocationHtml5Url(
400
+ const locationUrl = new Location(
415
401
  "http://server.org/base/abc",
416
402
  "http://server.org/base/",
403
+ true,
417
404
  );
418
405
 
419
406
  expect(() => {
420
- locationUrl.$$parse("http://other.server.org/path#/path");
407
+ locationUrl.parse("http://other.server.org/path#/path");
421
408
  }).toThrowError(/ipthprfx/);
422
409
  });
423
410
 
424
411
  it("should throw error when invalid base url given", () => {
425
- const locationUrl = new LocationHtml5Url(
412
+ const locationUrl = new Location(
426
413
  "http://server.org/base/abc",
427
414
  "http://server.org/base/",
415
+ true,
428
416
  );
429
417
 
430
418
  expect(() => {
431
- locationUrl.$$parse("http://server.org/path#/path");
419
+ locationUrl.parse("http://server.org/path#/path");
432
420
  }).toThrowError(/ipthprfx/);
433
421
  });
434
422
 
@@ -437,343 +425,800 @@ describe("$location", () => {
437
425
  const locationUrl = createLocationHtml5Url();
438
426
  expect(locationUrl.$$state).toEqual(undefined);
439
427
 
440
- const returned = locationUrl.state({ a: 2 });
428
+ const returned = locationUrl.setState({ a: 2 });
441
429
  expect(locationUrl.$$state).toEqual({ a: 2 });
442
430
  expect(returned).toBe(locationUrl);
443
431
  });
444
432
 
445
433
  it("should set state", () => {
446
434
  const locationUrl = createLocationHtml5Url();
447
- locationUrl.state({ a: 2 });
448
- expect(locationUrl.state()).toEqual({ a: 2 });
435
+ locationUrl.setState({ a: 2 });
436
+ expect(locationUrl.getState()).toEqual({ a: 2 });
449
437
  });
450
438
 
451
439
  it("should allow to set both URL and state", () => {
452
440
  const locationUrl = createLocationHtml5Url();
453
- locationUrl.url("/foo").state({ a: 2 });
454
- expect(locationUrl.url()).toEqual("/foo");
455
- expect(locationUrl.state()).toEqual({ a: 2 });
441
+ locationUrl.setUrl("/foo").setState({ a: 2 });
442
+ expect(locationUrl.getUrl()).toEqual("/foo");
443
+ expect(locationUrl.getState()).toEqual({ a: 2 });
456
444
  });
457
445
 
458
446
  it("should allow to mix state and various URL functions", () => {
459
447
  const locationUrl = createLocationHtml5Url();
460
448
  locationUrl
461
- .path("/foo")
462
- .hash("abcd")
463
- .state({ a: 2 })
464
- .search("bar", "baz");
465
-
466
- expect(locationUrl.path()).toEqual("/foo");
467
- expect(locationUrl.state()).toEqual({ a: 2 });
468
- expect(locationUrl.search() && locationUrl.search().bar).toBe("baz");
469
- expect(locationUrl.hash()).toEqual("abcd");
449
+ .setPath("/foo")
450
+ .setHash("abcd")
451
+ .setState({ a: 2 })
452
+ .setSearch("bar", "baz");
453
+
454
+ expect(locationUrl.getPath()).toEqual("/foo");
455
+ expect(locationUrl.getState()).toEqual({ a: 2 });
456
+ expect(locationUrl.getSearch() && locationUrl.getSearch().bar).toBe(
457
+ "baz",
458
+ );
459
+ expect(locationUrl.getHash()).toEqual("abcd");
470
460
  });
471
461
  });
472
462
 
473
463
  describe("encoding", () => {
474
464
  it("should encode special characters", () => {
475
465
  const locationUrl = createLocationHtml5Url();
476
- locationUrl.path("/a <>#");
477
- locationUrl.search({ "i j": "<>#" });
478
- locationUrl.hash("<>#");
479
-
480
- expect(locationUrl.path()).toBe("/a <>#");
481
- expect(locationUrl.search()).toEqual({ "i j": "<>#" });
482
- expect(locationUrl.hash()).toBe("<>#");
483
- expect(locationUrl.absUrl()).toBe(
466
+ locationUrl.setPath("/a <>#");
467
+ locationUrl.setSearch({ "i j": "<>#" });
468
+ locationUrl.setHash("<>#");
469
+
470
+ expect(locationUrl.getPath()).toBe("/a <>#");
471
+ expect(locationUrl.getSearch()).toEqual({ "i j": "<>#" });
472
+ expect(locationUrl.getHash()).toBe("<>#");
473
+ expect(locationUrl.absUrl).toBe(
484
474
  "http://www.domain.com:9877/a%20%3C%3E%23?i%20j=%3C%3E%23#%3C%3E%23",
485
475
  );
486
476
  });
487
477
 
488
478
  it("should not encode !$:@", () => {
489
479
  const locationUrl = createLocationHtml5Url();
490
- locationUrl.path("/!$:@");
491
- locationUrl.search("");
492
- locationUrl.hash("!$:@");
480
+ locationUrl.setPath("/!$:@");
481
+ locationUrl.setSearch("");
482
+ locationUrl.setHash("!$:@");
493
483
 
494
- expect(locationUrl.absUrl()).toBe(
495
- "http://www.domain.com:9877/!$:@#!$:@",
496
- );
484
+ expect(locationUrl.absUrl).toBe("http://www.domain.com:9877/!$:@#!$:@");
497
485
  });
498
486
 
499
487
  it("should decode special characters", () => {
500
- const locationUrl = new LocationHtml5Url(
488
+ const locationUrl = new Location(
501
489
  "http://host.com/",
502
490
  "http://host.com/",
491
+ true,
503
492
  );
504
- locationUrl.$$parse(
493
+ locationUrl.parse(
505
494
  "http://host.com/a%20%3C%3E%23?i%20j=%3C%3E%23#x%20%3C%3E%23",
506
495
  );
507
- expect(locationUrl.path()).toBe("/a <>#");
508
- expect(locationUrl.search()).toEqual({ "i j": "<>#" });
509
- expect(locationUrl.hash()).toBe("x <>#");
496
+ expect(locationUrl.getPath()).toBe("/a <>#");
497
+ expect(locationUrl.getSearch()).toEqual({ "i j": "<>#" });
498
+ expect(locationUrl.getHash()).toBe("x <>#");
510
499
  });
511
500
 
512
501
  it("should not decode encoded forward slashes in the path", () => {
513
- const locationUrl = new LocationHtml5Url(
502
+ const locationUrl = new Location(
514
503
  "http://host.com/base/",
515
504
  "http://host.com/base/",
505
+ true,
516
506
  );
517
- locationUrl.$$parse("http://host.com/base/a/ng2;path=%2Fsome%2Fpath");
518
- expect(locationUrl.path()).toBe("/a/ng2;path=%2Fsome%2Fpath");
519
- expect(locationUrl.search()).toEqual({});
520
- expect(locationUrl.hash()).toBe("");
521
- expect(locationUrl.url()).toBe("/a/ng2;path=%2Fsome%2Fpath");
522
- expect(locationUrl.absUrl()).toBe(
507
+ locationUrl.parse("http://host.com/base/a/ng2;path=%2Fsome%2Fpath");
508
+ expect(locationUrl.getPath()).toBe("/a/ng2;path=%2Fsome%2Fpath");
509
+ expect(locationUrl.getSearch()).toEqual({});
510
+ expect(locationUrl.getHash()).toBe("");
511
+ expect(locationUrl.getUrl()).toBe("/a/ng2;path=%2Fsome%2Fpath");
512
+ expect(locationUrl.absUrl).toBe(
523
513
  "http://host.com/base/a/ng2;path=%2Fsome%2Fpath",
524
514
  );
525
515
  });
526
516
 
527
517
  it("should decode pluses as spaces in urls", () => {
528
- const locationUrl = new LocationHtml5Url(
518
+ const locationUrl = new Location(
529
519
  "http://host.com/",
530
520
  "http://host.com/",
521
+ true,
531
522
  );
532
- locationUrl.$$parse("http://host.com/?a+b=c+d");
533
- expect(locationUrl.search()).toEqual({ "a b": "c d" });
523
+ locationUrl.parse("http://host.com/?a+b=c+d");
524
+ expect(locationUrl.getSearch()).toEqual({ "a b": "c d" });
534
525
  });
535
526
 
536
527
  it("should retain pluses when setting search queries", () => {
537
528
  const locationUrl = createLocationHtml5Url();
538
- locationUrl.search({ "a+b": "c+d" });
539
- expect(locationUrl.search()).toEqual({ "a+b": "c+d" });
529
+ locationUrl.setSearch({ "a+b": "c+d" });
530
+ expect(locationUrl.getSearch()).toEqual({ "a+b": "c+d" });
540
531
  });
541
532
  });
542
533
  });
543
534
 
544
535
  describe("HashbangUrl", () => {
545
536
  function createHashbangUrl() {
546
- const locationUrl = new LocationHashbangUrl(
537
+ const locationUrl = new Location(
547
538
  "http://www.server.org:1234/base",
548
539
  "http://www.server.org:1234/",
540
+ false,
549
541
  "#!",
550
542
  );
551
- locationUrl.$$parse("http://www.server.org:1234/base#!/path?a=b&c#hash");
543
+ locationUrl.parse("http://www.server.org:1234/base#!/path?a=b&c#hash");
552
544
  return locationUrl;
553
545
  }
554
546
 
555
547
  it("should parse hashbang url into path and search", () => {
556
548
  const locationUrl = createHashbangUrl();
557
- expect(locationUrl.protocol()).toBe("http");
558
- expect(locationUrl.host()).toBe("www.server.org");
559
- expect(locationUrl.port()).toBe(1234);
560
- expect(locationUrl.path()).toBe("/path");
561
- expect(locationUrl.search()).toEqual({ a: "b", c: true });
562
- expect(locationUrl.hash()).toBe("hash");
549
+ expect(locationUrl.getPath()).toBe("/path");
550
+ expect(locationUrl.getSearch()).toEqual({ a: "b", c: true });
551
+ expect(locationUrl.getHash()).toBe("hash");
563
552
  });
564
553
 
565
- it("absUrl() should return hashbang url", () => {
554
+ it("absUrl should return hashbang url", () => {
566
555
  const locationUrl = createHashbangUrl();
567
- expect(locationUrl.absUrl()).toBe(
556
+ expect(locationUrl.absUrl).toBe(
568
557
  "http://www.server.org:1234/base#!/path?a=b&c#hash",
569
558
  );
570
559
 
571
- locationUrl.path("/new/path");
572
- locationUrl.search({ one: 1 });
573
- locationUrl.hash("hhh");
574
- expect(locationUrl.absUrl()).toBe(
560
+ locationUrl.setPath("/new/path");
561
+ locationUrl.setSearch({ one: 1 });
562
+ locationUrl.setHash("hhh");
563
+ expect(locationUrl.absUrl).toBe(
575
564
  "http://www.server.org:1234/base#!/new/path?one=1#hhh",
576
565
  );
577
566
  });
578
567
 
579
568
  it("should preserve query params in base", () => {
580
- const locationUrl = new LocationHashbangUrl(
569
+ const locationUrl = new Location(
581
570
  "http://www.server.org:1234/base?base=param",
582
571
  "http://www.server.org:1234/",
572
+ false,
583
573
  "#",
584
574
  );
585
- locationUrl.$$parse(
575
+ locationUrl.parse(
586
576
  "http://www.server.org:1234/base?base=param#/path?a=b&c#hash",
587
577
  );
588
- expect(locationUrl.absUrl()).toBe(
578
+ expect(locationUrl.absUrl).toBe(
589
579
  "http://www.server.org:1234/base?base=param#/path?a=b&c#hash",
590
580
  );
591
581
 
592
- locationUrl.path("/new/path");
593
- locationUrl.search({ one: 1 });
594
- locationUrl.hash("hhh");
595
- expect(locationUrl.absUrl()).toBe(
582
+ locationUrl.setPath("/new/path");
583
+ locationUrl.setSearch({ one: 1 });
584
+ locationUrl.setHash("hhh");
585
+ expect(locationUrl.absUrl).toBe(
596
586
  "http://www.server.org:1234/base?base=param#/new/path?one=1#hhh",
597
587
  );
598
588
  });
599
589
 
600
590
  it("should prefix path with forward-slash", () => {
601
- const locationUrl = new LocationHashbangUrl(
591
+ const locationUrl = new Location(
602
592
  "http://host.com/base",
603
593
  "http://host.com/",
594
+ false,
604
595
  "#",
605
596
  );
606
- locationUrl.$$parse("http://host.com/base#path");
607
- expect(locationUrl.path()).toBe("/path");
608
- expect(locationUrl.absUrl()).toBe("http://host.com/base#/path");
597
+ locationUrl.parse("http://host.com/base#path");
598
+ expect(locationUrl.getPath()).toBe("/path");
599
+ expect(locationUrl.absUrl).toBe("http://host.com/base#/path");
609
600
 
610
- locationUrl.path("wrong");
611
- expect(locationUrl.path()).toBe("/wrong");
612
- expect(locationUrl.absUrl()).toBe("http://host.com/base#/wrong");
601
+ locationUrl.setPath("wrong");
602
+ expect(locationUrl.getPath()).toBe("/wrong");
603
+ expect(locationUrl.absUrl).toBe("http://host.com/base#/wrong");
613
604
  });
614
605
 
615
606
  it("should set path to forward-slash when empty", () => {
616
- const locationUrl = new LocationHashbangUrl(
607
+ const locationUrl = new Location(
617
608
  "http://server/base",
618
609
  "http://server/",
610
+ false,
619
611
  "#!",
620
612
  );
621
- locationUrl.$$parse("http://server/base");
622
- locationUrl.path("aaa");
613
+ locationUrl.parse("http://server/base");
614
+ locationUrl.setPath("aaa");
623
615
 
624
- expect(locationUrl.path()).toBe("/aaa");
625
- expect(locationUrl.absUrl()).toBe("http://server/base#!/aaa");
616
+ expect(locationUrl.getPath()).toBe("/aaa");
617
+ expect(locationUrl.absUrl).toBe("http://server/base#!/aaa");
626
618
  });
627
619
 
628
620
  it("should not preserve old properties when parsing new url", () => {
629
621
  const locationUrl = createHashbangUrl();
630
- locationUrl.$$parse("http://www.server.org:1234/base#!/");
622
+ locationUrl.parse("http://www.server.org:1234/base#!/");
631
623
 
632
- expect(locationUrl.path()).toBe("/");
633
- expect(locationUrl.search()).toEqual({});
634
- expect(locationUrl.hash()).toBe("");
635
- expect(locationUrl.absUrl()).toBe("http://www.server.org:1234/base#!/");
624
+ expect(locationUrl.getPath()).toBe("/");
625
+ expect(locationUrl.getSearch()).toEqual({});
626
+ expect(locationUrl.getHash()).toBe("");
627
+ expect(locationUrl.absUrl).toBe("http://www.server.org:1234/base#!/");
636
628
  });
637
629
 
638
630
  it("should insert default hashbang if a hash is given with no hashbang prefix", () => {
639
631
  const locationUrl = createHashbangUrl();
640
632
 
641
- locationUrl.$$parse("http://www.server.org:1234/base#/path");
642
- expect(locationUrl.absUrl()).toBe(
633
+ locationUrl.parse("http://www.server.org:1234/base#/path");
634
+ expect(locationUrl.absUrl).toBe(
643
635
  "http://www.server.org:1234/base#!#%2Fpath",
644
636
  );
645
- expect(locationUrl.hash()).toBe("/path");
646
- expect(locationUrl.path()).toBe("");
637
+ expect(locationUrl.getHash()).toBe("/path");
638
+ expect(locationUrl.getPath()).toBe("");
647
639
 
648
- locationUrl.$$parse("http://www.server.org:1234/base#");
649
- expect(locationUrl.absUrl()).toBe("http://www.server.org:1234/base");
650
- expect(locationUrl.hash()).toBe("");
651
- expect(locationUrl.path()).toBe("");
640
+ locationUrl.parse("http://www.server.org:1234/base#");
641
+ expect(locationUrl.absUrl).toBe("http://www.server.org:1234/base");
642
+ expect(locationUrl.getHash()).toBe("");
643
+ expect(locationUrl.getPath()).toBe("");
652
644
  });
653
645
 
654
646
  it("should ignore extra path segments if no hashbang is given", () => {
655
647
  const locationUrl = createHashbangUrl();
656
- locationUrl.$$parse("http://www.server.org:1234/base/extra/path");
657
- expect(locationUrl.absUrl()).toBe("http://www.server.org:1234/base");
658
- expect(locationUrl.path()).toBe("");
659
- expect(locationUrl.hash()).toBe("");
648
+ locationUrl.parse("http://www.server.org:1234/base/extra/path");
649
+ expect(locationUrl.absUrl).toBe("http://www.server.org:1234/base");
650
+ expect(locationUrl.getPath()).toBe("");
651
+ expect(locationUrl.getHash()).toBe("");
660
652
  });
661
653
 
662
654
  describe("encoding", () => {
663
655
  it("should encode special characters", () => {
664
656
  const locationUrl = createHashbangUrl();
665
- locationUrl.path("/a <>#");
666
- locationUrl.search({ "i j": "<>#" });
667
- locationUrl.hash("<>#");
668
-
669
- expect(locationUrl.path()).toBe("/a <>#");
670
- expect(locationUrl.search()).toEqual({ "i j": "<>#" });
671
- expect(locationUrl.hash()).toBe("<>#");
672
- expect(locationUrl.absUrl()).toBe(
657
+ locationUrl.setPath("/a <>#");
658
+ locationUrl.setSearch({ "i j": "<>#" });
659
+ locationUrl.setHash("<>#");
660
+
661
+ expect(locationUrl.getPath()).toBe("/a <>#");
662
+ expect(locationUrl.getSearch()).toEqual({ "i j": "<>#" });
663
+ expect(locationUrl.getHash()).toBe("<>#");
664
+ expect(locationUrl.absUrl).toBe(
673
665
  "http://www.server.org:1234/base#!/a%20%3C%3E%23?i%20j=%3C%3E%23#%3C%3E%23",
674
666
  );
675
667
  });
676
668
 
677
669
  it("should not encode !$:@", () => {
678
670
  const locationUrl = createHashbangUrl();
679
- locationUrl.path("/!$:@");
680
- locationUrl.search("");
681
- locationUrl.hash("!$:@");
671
+ locationUrl.setPath("/!$:@");
672
+ locationUrl.setSearch("");
673
+ locationUrl.setHash("!$:@");
682
674
 
683
- expect(locationUrl.absUrl()).toBe(
675
+ expect(locationUrl.absUrl).toBe(
684
676
  "http://www.server.org:1234/base#!/!$:@#!$:@",
685
677
  );
686
678
  });
687
679
 
688
680
  it("should decode special characters", () => {
689
- const locationUrl = new LocationHashbangUrl(
681
+ const locationUrl = new Location(
690
682
  "http://host.com/a",
691
683
  "http://host.com/",
684
+ false,
692
685
  "#",
693
686
  );
694
- locationUrl.$$parse(
687
+ locationUrl.parse(
695
688
  "http://host.com/a#/%20%3C%3E%23?i%20j=%3C%3E%23#x%20%3C%3E%23",
696
689
  );
697
- expect(locationUrl.path()).toBe("/ <>#");
698
- expect(locationUrl.search()).toEqual({ "i j": "<>#" });
699
- expect(locationUrl.hash()).toBe("x <>#");
690
+ expect(locationUrl.getPath()).toBe("/ <>#");
691
+ expect(locationUrl.getSearch()).toEqual({ "i j": "<>#" });
692
+ expect(locationUrl.getHash()).toBe("x <>#");
700
693
  });
701
694
 
702
695
  it("should return decoded characters for search specified in URL", () => {
703
- const locationUrl = new LocationHtml5Url(
696
+ const locationUrl = new Location(
704
697
  "http://host.com/",
705
698
  "http://host.com/",
699
+ true,
706
700
  );
707
- locationUrl.$$parse("http://host.com/?q=1%2F2%203");
708
- expect(locationUrl.search()).toEqual({ q: "1/2 3" });
701
+ locationUrl.parse("http://host.com/?q=1%2F2%203");
702
+ expect(locationUrl.getSearch()).toEqual({ q: "1/2 3" });
709
703
  });
710
704
 
711
705
  it("should return decoded characters for search specified with setter", () => {
712
- const locationUrl = new LocationHtml5Url(
706
+ const locationUrl = new Location(
713
707
  "http://host.com/",
714
708
  "http://host.com/",
709
+ true,
715
710
  );
716
- locationUrl.$$parse("http://host.com/");
717
- locationUrl.search("q", "1/2 3");
718
- expect(locationUrl.search()).toEqual({ q: "1/2 3" });
711
+ locationUrl.parse("http://host.com/");
712
+ locationUrl.setSearch("q", "1/2 3");
713
+ expect(locationUrl.getSearch()).toEqual({ q: "1/2 3" });
719
714
  });
720
715
 
721
716
  it("should return an array for duplicate params", () => {
722
- const locationUrl = new LocationHtml5Url(
717
+ const locationUrl = new Location(
723
718
  "http://host.com",
724
719
  "http://host.com",
720
+ true,
725
721
  );
726
- locationUrl.$$parse("http://host.com");
727
- locationUrl.search("q", ["1/2 3", "4/5 6"]);
728
- expect(locationUrl.search()).toEqual({ q: ["1/2 3", "4/5 6"] });
722
+ locationUrl.parse("http://host.com");
723
+ locationUrl.setSearch("q", ["1/2 3", "4/5 6"]);
724
+ expect(locationUrl.getSearch()).toEqual({ q: ["1/2 3", "4/5 6"] });
729
725
  });
730
726
 
731
727
  it("should encode an array correctly from search and add to url", () => {
732
- const locationUrl = new LocationHtml5Url(
728
+ const locationUrl = new Location(
733
729
  "http://host.com",
734
730
  "http://host.com",
731
+ true,
735
732
  );
736
- locationUrl.$$parse("http://host.com");
737
- locationUrl.search({ q: ["1/2 3", "4/5 6"] });
738
- expect(locationUrl.absUrl()).toEqual(
733
+ locationUrl.parse("http://host.com");
734
+ locationUrl.setSearch({ q: ["1/2 3", "4/5 6"] });
735
+ expect(locationUrl.absUrl).toEqual(
739
736
  "http://host.com?q=1%2F2%203&q=4%2F5%206",
740
737
  );
741
738
  });
742
739
 
743
740
  it("should rewrite params when specifying a single param in search", () => {
744
- const locationUrl = new LocationHtml5Url(
741
+ const locationUrl = new Location(
745
742
  "http://host.com",
746
743
  "http://host.com",
744
+ true,
747
745
  );
748
- locationUrl.$$parse("http://host.com");
749
- locationUrl.search({ q: "1/2 3" });
750
- expect(locationUrl.absUrl()).toEqual("http://host.com?q=1%2F2%203");
751
- locationUrl.search({ q: "4/5 6" });
752
- expect(locationUrl.absUrl()).toEqual("http://host.com?q=4%2F5%206");
746
+ locationUrl.parse("http://host.com");
747
+ locationUrl.setSearch({ q: "1/2 3" });
748
+ expect(locationUrl.absUrl).toEqual("http://host.com?q=1%2F2%203");
749
+ locationUrl.setSearch({ q: "4/5 6" });
750
+ expect(locationUrl.absUrl).toEqual("http://host.com?q=4%2F5%206");
753
751
  });
754
752
 
755
- it("url() should decode non-component special characters in hashbang mode", () => {
756
- const locationUrl = new LocationHashbangUrl(
753
+ it("url getter/setter should decode non-component special characters in hashbang mode", () => {
754
+ const locationUrl = new Location(
757
755
  "http://host.com",
758
756
  "http://host.com",
757
+ false,
759
758
  );
760
- locationUrl.$$parse("http://host.com");
761
- locationUrl.url("/foo%3Abar");
762
- expect(locationUrl.path()).toEqual("/foo:bar");
759
+ locationUrl.parse("http://host.com");
760
+ locationUrl.setUrl("/foo%3Abar");
761
+ expect(locationUrl.getPath()).toEqual("/foo:bar");
763
762
  });
764
763
 
765
- it("url() should decode non-component special characters in html5 mode", () => {
766
- const locationUrl = new LocationHtml5Url(
764
+ it("url getter/setter should decode non-component special characters in html5 mode", () => {
765
+ const locationUrl = new Location(
767
766
  "http://host.com",
768
767
  "http://host.com",
768
+ true,
769
769
  );
770
- locationUrl.$$parse("http://host.com");
771
- locationUrl.url("/foo%3Abar");
772
- expect(locationUrl.path()).toEqual("/foo:bar");
770
+ locationUrl.parse("http://host.com");
771
+ locationUrl.setUrl("/foo%3Abar");
772
+ expect(locationUrl.getPath()).toEqual("/foo:bar");
773
773
  });
774
774
  });
775
775
  });
776
776
 
777
+ describe("encodePath", () => {
778
+ it("should encode each segment but preserve slashes", () => {
779
+ const input = "user profile/images/pic 1.jpg";
780
+ const result = encodePath(input);
781
+ expect(result).toBe("user%20profile/images/pic%201.jpg");
782
+ });
783
+
784
+ it("should re-encode previously encoded forward slashes as literal slashes", () => {
785
+ const input = "folder1%2Fsub/folder2";
786
+ const result = encodePath(input);
787
+ expect(result).toBe("folder1%2Fsub/folder2");
788
+ });
789
+
790
+ it("should handle special characters properly", () => {
791
+ const input = "a$bc/def@gh";
792
+ const result = encodePath(input);
793
+ expect(result).toBe("a$bc/def@gh");
794
+ });
795
+
796
+ it("should return empty string for empty path", () => {
797
+ const input = "";
798
+ const result = encodePath(input);
799
+ expect(result).toBe("");
800
+ });
801
+
802
+ it("should handle single segment", () => {
803
+ const input = "hello world";
804
+ const result = encodePath(input);
805
+ expect(result).toBe("hello%20world");
806
+ });
807
+
808
+ it("should not double encode already encoded segments except slashes", () => {
809
+ const input = "one%20two/three%2Ffour";
810
+ const result = encodePath(input);
811
+ expect(result).toBe("one%20two/three%2Ffour");
812
+ });
813
+
814
+ it("should not double encode already encoded segments", () => {
815
+ const input = "double%20encoded";
816
+ const result = encodePath(input);
817
+ expect(result).toBe("double%20encoded");
818
+ });
819
+
820
+ it("should preserve double encoded segments as-is (single decode only)", () => {
821
+ const input = "double%2520encoded";
822
+ const result = encodePath(input);
823
+ expect(result).toBe("double%2520encoded"); // double % stays double encoded
824
+ });
825
+
826
+ it("should preserve leading and trailing slashes", () => {
827
+ const input = "/a b/c d/";
828
+ const result = encodePath(input);
829
+ expect(result).toBe("/a%20b/c%20d/");
830
+ });
831
+
832
+ it("should preserve multiple consecutive slashes as empty segments", () => {
833
+ const input = "foo//bar///baz";
834
+ const result = encodePath(input);
835
+ expect(result).toBe("foo//bar///baz");
836
+ });
837
+
838
+ it("should not encode RFC 3986 reserved characters in segments", () => {
839
+ const input = "key=value/param+test";
840
+ const result = encodePath(input);
841
+ expect(result).toBe("key=value/param+test");
842
+ });
843
+
844
+ it("should encode unicode characters properly", () => {
845
+ const input = "café/naïve";
846
+ const result = encodePath(input);
847
+ expect(result).toBe("caf%C3%A9/na%C3%AFve");
848
+ });
849
+
850
+ it("should handle input with only slashes", () => {
851
+ const input = "///";
852
+ const result = encodePath(input);
853
+ expect(result).toBe("///");
854
+ });
855
+
856
+ it("should treat encoded slashes as literal and decoded slashes as separators", () => {
857
+ const input = "part1%2Fsub/part2";
858
+ const result = encodePath(input);
859
+ expect(result).toBe("part1%2Fsub/part2");
860
+ });
861
+ });
862
+
863
+ describe("decodePath", () => {
864
+ it("should decode percent-encoded segments", () => {
865
+ const input = "hello%20world/abc%40def";
866
+ const result = decodePath(input, false);
867
+ expect(result).toBe("hello world/abc@def");
868
+ });
869
+
870
+ it("should encode slashes as %2F in html5Mode", () => {
871
+ const input = "section%2Fname/data";
872
+ const result = decodePath(input, true);
873
+ expect(result).toBe("section%2Fname/data");
874
+ });
875
+
876
+ it("should preserve decoded forward slashes in html5Mode", () => {
877
+ const input = "foo/bar%2Fbaz/qux";
878
+ const result = decodePath(input, true);
879
+ // 'bar/baz' becomes 'bar%2Fbaz'
880
+ expect(result).toBe("foo/bar%2Fbaz/qux");
881
+ });
882
+
883
+ it("should not change decoded slashes when html5Mode is false", () => {
884
+ const input = "foo/bar%2Fbaz/qux";
885
+ const result = decodePath(input, false);
886
+ expect(result).toBe("foo/bar/baz/qux");
887
+ });
888
+
889
+ it("should handle empty segments correctly", () => {
890
+ const input = "a//b";
891
+ const result = decodePath(input, false);
892
+ expect(result).toBe("a//b"); // empty segment remains
893
+ });
894
+
895
+ it("should decode already decoded values without errors", () => {
896
+ const input = "simple/path";
897
+ const result = decodePath(input, false);
898
+ expect(result).toBe("simple/path");
899
+ });
900
+
901
+ it("should decode and re-encode all forward slashes in segments when html5Mode is true", () => {
902
+ const input = "a%2Fb/c%2Fd";
903
+ const result = decodePath(input, true);
904
+ expect(result).toBe("a%2Fb/c%2Fd");
905
+ });
906
+
907
+ it("should return an empty string if given an empty string", () => {
908
+ expect(decodePath("", false)).toBe("");
909
+ expect(decodePath("", true)).toBe("");
910
+ });
911
+
912
+ it("should decode double-encoded segments only once", () => {
913
+ const input = "double%2520encoded"; // '%2520' = '%20'
914
+ const result = decodePath(input, false);
915
+ expect(result).toBe("double%20encoded"); // Only decode once
916
+ });
917
+
918
+ it("should correctly decode reserved URI characters", () => {
919
+ const input = "%3A%3B%26%3D";
920
+ const result = decodePath(input, false);
921
+ expect(result).toBe(":;&=");
922
+ });
923
+
924
+ it("should throw URIError for malformed percent encodings", () => {
925
+ const input = "bad%encoding";
926
+ expect(() => decodePath(input, false)).toThrowError(URIError);
927
+ });
928
+
929
+ it("should preserve leading and trailing empty segments", () => {
930
+ const input = "/path/with/trailing/";
931
+ const result = decodePath(input, false);
932
+ expect(result).toBe("/path/with/trailing/");
933
+ });
934
+
935
+ it("should re-encode slashes inside segments when html5Mode is true", () => {
936
+ const input = "path%2Fsegment/next";
937
+ const result = decodePath(input, true);
938
+ expect(result).toBe("path%2Fsegment/next");
939
+ });
940
+
941
+ it("should handle completely empty segments (multiple slashes)", () => {
942
+ const input = "///";
943
+ const result = decodePath(input, false);
944
+ expect(result).toBe("///");
945
+ });
946
+ });
947
+
948
+ describe("normalizePath", () => {
949
+ it("should encode the path, append search and hash correctly", () => {
950
+ const path = "folder name/file name";
951
+ const search = { q: "test", page: "1" };
952
+ const hash = "section 2";
953
+
954
+ const result = normalizePath(path, search, hash);
955
+ expect(result).toBe(
956
+ "folder%20name/file%20name?q=test&page=1#section%202",
957
+ );
958
+ });
959
+
960
+ it("should return path only if no search and no hash", () => {
961
+ const path = "simple/path";
962
+ const result = normalizePath(path, null, null);
963
+ expect(result).toBe("simple/path");
964
+ });
965
+
966
+ it("should correctly encode search params from object", () => {
967
+ const search = { a: "1", b: "2" };
968
+ const result = normalizePath("path", search, null);
969
+ expect(result).toBe("path?a=1&b=2");
970
+ });
971
+
972
+ it("should correctly encode array values in search", () => {
973
+ const search = { a: ["1", "2"] };
974
+ const result = normalizePath("path", search, null);
975
+ // Expected: a=1&a=2 (both keys repeated)
976
+ expect(result).toBe("path?a=1&a=2");
977
+ });
978
+
979
+ it("should handle boolean true values", () => {
980
+ const search = { flag: true };
981
+ const result = normalizePath("path", search, null);
982
+ expect(result).toBe("path?flag");
983
+ });
984
+
985
+ it("should encode hash value properly", () => {
986
+ const path = "path";
987
+ const hash = "hello world";
988
+ const result = normalizePath(path, null, hash);
989
+ expect(result).toBe("path#hello%20world");
990
+ });
991
+
992
+ it("should not append ? if search is empty string or empty object", () => {
993
+ expect(normalizePath("path", "", "hash")).toBe("path#hash");
994
+ expect(normalizePath("path", {}, "hash")).toBe("path#hash");
995
+ });
996
+
997
+ it("should handle empty path gracefully", () => {
998
+ const result = normalizePath("", { a: "1" }, "h");
999
+ expect(result).toBe("?a=1#h");
1000
+ });
1001
+ });
1002
+
1003
+ describe("parseAppUrl", () => {
1004
+ let locationObj;
1005
+
1006
+ beforeEach(() => {
1007
+ locationObj = new Location(
1008
+ "http://www.domain.com:9877/",
1009
+ "http://www.domain.com:9877/",
1010
+ );
1011
+ });
1012
+
1013
+ it("should throw error on url starting with // or \\\\", () => {
1014
+ expect(() => parseAppUrl("//invalid/path", false)).toThrowError(
1015
+ /Invalid url/,
1016
+ );
1017
+ expect(() => parseAppUrl("\\\\invalid\\path", false)).toThrowError(
1018
+ /Invalid url/,
1019
+ );
1020
+ });
1021
+
1022
+ it("should add leading slash if missing and parse url correctly", () => {
1023
+ parseAppUrl("some/path?foo=bar#hashValue", false);
1024
+ expect(locationObj.getPath()).toBe("/some/path");
1025
+ expect(locationObj.getSearch()).toEqual(
1026
+ jasmine.objectContaining({ foo: "bar" }),
1027
+ );
1028
+ expect(locationObj.getHash()).toBe("hashValue");
1029
+ });
1030
+
1031
+ it("should keep leading slash if present", () => {
1032
+ parseAppUrl("/already/slashed?x=1#abc", locationObj, false);
1033
+ expect(locationObj.getPath()).toBe("/already/slashed");
1034
+ expect(locationObj.getSearch()).toEqual(
1035
+ jasmine.objectContaining({ x: "1" }),
1036
+ );
1037
+ expect(locationObj.getHash()).toBe("abc");
1038
+ });
1039
+
1040
+ it("should remove leading slash from path if prefixed and path starts with slash", () => {
1041
+ parseAppUrl("foo/bar", locationObj, false);
1042
+ expect(locationObj.getPath().charAt(0)).toBe("/");
1043
+ expect(locationObj.getPath()).toBe("/foo/bar");
1044
+ });
1045
+
1046
+ it("should set empty $$search when no query params", () => {
1047
+ parseAppUrl("/pathOnly", locationObj, false);
1048
+ expect(locationObj.getSearch()).toEqual({});
1049
+ });
1050
+
1051
+ it("should decode hash correctly", () => {
1052
+ parseAppUrl("/path#%23encoded", locationObj, false);
1053
+ expect(locationObj.getHash()).toBe("#encoded");
1054
+ });
1055
+ });
1056
+
1057
+ describe("stripBaseUrl", () => {
1058
+ it("should return substring after base if url starts with base", () => {
1059
+ expect(stripBaseUrl("/base", "/base/some/path")).toBe("/some/path");
1060
+ expect(
1061
+ stripBaseUrl("http://example.com", "http://example.com/page"),
1062
+ ).toBe("/page");
1063
+ expect(stripBaseUrl("", "/anything")).toBe("/anything"); // empty base returns full url
1064
+ });
1065
+
1066
+ it("should return empty string if url equals base", () => {
1067
+ expect(stripBaseUrl("/base", "/base")).toBe("");
1068
+ });
1069
+
1070
+ it("should return undefined if url does not start with base", () => {
1071
+ expect(stripBaseUrl("/base", "/notbase/something")).toBeUndefined();
1072
+ expect(
1073
+ stripBaseUrl("http://example.com", "https://example.com/page"),
1074
+ ).toBeUndefined();
1075
+ });
1076
+
1077
+ it("should handle base being longer than url", () => {
1078
+ expect(stripBaseUrl("/longer/base", "/short")).toBeUndefined();
1079
+ });
1080
+
1081
+ it("should be case sensitive", () => {
1082
+ expect(stripBaseUrl("/Base", "/base/something")).toBeUndefined();
1083
+ });
1084
+ });
1085
+
1086
+ describe("stripHash", () => {
1087
+ it("should return the same URL if there is no hash", () => {
1088
+ expect(stripHash("http://example.com/path")).toBe(
1089
+ "http://example.com/path",
1090
+ );
1091
+ expect(stripHash("/some/path")).toBe("/some/path");
1092
+ });
1093
+
1094
+ it("should remove the hash and everything after it", () => {
1095
+ expect(stripHash("http://example.com/path#section1")).toBe(
1096
+ "http://example.com/path",
1097
+ );
1098
+ expect(stripHash("/path/to/resource#hashvalue")).toBe(
1099
+ "/path/to/resource",
1100
+ );
1101
+ });
1102
+
1103
+ it("should remove hash even if it is at the very end", () => {
1104
+ expect(stripHash("http://example.com/#")).toBe("http://example.com/");
1105
+ });
1106
+
1107
+ it("should handle empty string input", () => {
1108
+ expect(stripHash("")).toBe("");
1109
+ });
1110
+
1111
+ it("should handle hash only string", () => {
1112
+ expect(stripHash("#hashonly")).toBe("");
1113
+ });
1114
+ });
1115
+
1116
+ describe("stripFile", () => {
1117
+ it("removes filename from URL without hash", () => {
1118
+ const input = "https://example.com/path/to/file.js";
1119
+ const expected = "https://example.com/path/to/";
1120
+ expect(stripFile(input)).toBe(expected);
1121
+ });
1122
+
1123
+ it("removes filename and hash from URL", () => {
1124
+ const input = "https://example.com/path/to/file.js#section";
1125
+ const expected = "https://example.com/path/to/";
1126
+ expect(stripFile(input)).toBe(expected);
1127
+ });
1128
+
1129
+ it("handles root URL with file", () => {
1130
+ const input = "https://example.com/file.js";
1131
+ const expected = "https://example.com/";
1132
+ expect(stripFile(input)).toBe(expected);
1133
+ });
1134
+
1135
+ it("handles URL with no file", () => {
1136
+ const input = "https://example.com/path/to/";
1137
+ const expected = "https://example.com/path/to/";
1138
+ expect(stripFile(input)).toBe(expected);
1139
+ });
1140
+
1141
+ it("handles relative URL with file and hash", () => {
1142
+ const input = "docs/static/app.js#v1";
1143
+ const expected = "docs/static/";
1144
+ expect(stripFile(input)).toBe(expected);
1145
+ });
1146
+ });
1147
+
1148
+ describe("serverBase", () => {
1149
+ it("returns server base for https URL without port", () => {
1150
+ const input = "https://example.com/path/to/resource";
1151
+ const expected = "https://example.com";
1152
+ expect(serverBase(input)).toBe(expected);
1153
+ });
1154
+
1155
+ it("returns server base for http URL with port", () => {
1156
+ const input = "http://localhost:8080/api/data";
1157
+ const expected = "http://localhost:8080";
1158
+ expect(serverBase(input)).toBe(expected);
1159
+ });
1160
+
1161
+ it("returns server base for URL with subdomain", () => {
1162
+ const input = "https://api.example.com/v1/query";
1163
+ const expected = "https://api.example.com";
1164
+ expect(serverBase(input)).toBe(expected);
1165
+ });
1166
+
1167
+ it("returns full URL if no path is present", () => {
1168
+ const input = "https://example.com";
1169
+ const expected = "https://example.com";
1170
+ expect(serverBase(input)).toBe(expected);
1171
+ });
1172
+
1173
+ it("handles trailing slash after host", () => {
1174
+ const input = "https://example.com/";
1175
+ const expected = "https://example.com";
1176
+ expect(serverBase(input)).toBe(expected);
1177
+ });
1178
+ });
1179
+
1180
+ describe("urlsEqual", () => {
1181
+ it("matches same URL", () => {
1182
+ expect(
1183
+ urlsEqual("http://example.com/foo", "http://example.com/foo"),
1184
+ ).toBe(true);
1185
+ });
1186
+
1187
+ it("ignores trailing slash", () => {
1188
+ expect(
1189
+ urlsEqual("http://example.com/foo/", "http://example.com/foo"),
1190
+ ).toBe(true);
1191
+ });
1192
+
1193
+ it("ignores encoded spaces", () => {
1194
+ expect(
1195
+ urlsEqual("http://example.com/foo%20bar", "http://example.com/foo bar"),
1196
+ ).toBe(true);
1197
+ });
1198
+
1199
+ it("ignores empty hash", () => {
1200
+ expect(
1201
+ urlsEqual("http://example.com/foo#", "http://example.com/foo"),
1202
+ ).toBe(true);
1203
+ });
1204
+
1205
+ it("resolves relative to base href", () => {
1206
+ const base = document.createElement("base");
1207
+ base.href = "http://localhost/";
1208
+ document.head.appendChild(base);
1209
+
1210
+ expect(urlsEqual("/bar", "http://localhost/bar")).toBe(true);
1211
+
1212
+ document.head.removeChild(base); // cleanup
1213
+ });
1214
+
1215
+ it("returns false for different paths", () => {
1216
+ expect(
1217
+ urlsEqual("http://example.com/foo", "http://example.com/bar"),
1218
+ ).toBe(false);
1219
+ });
1220
+ });
1221
+
777
1222
  // describe("location watch", () => {
778
1223
  // it("should not update browser if only the empty hash fragment is cleared", () => {
779
1224
  // initService({ supportHistory: true });
@@ -794,7 +1239,7 @@ describe("$location", () => {
794
1239
  // mockUpBrowser({ initialUrl: "http://new.com/#", baseHref: "/" });
795
1240
  // inject(($browser, $location, $window) => {
796
1241
  // expect($browser.url()).toBe("http://new.com/");
797
- // expect($location.absUrl()).toBe("http://new.com/");
1242
+ // expect($location.absUrl).toBe("http://new.com/");
798
1243
  // expect($window.location.href).toBe("http://new.com/#");
799
1244
  // });
800
1245
  // });
@@ -809,8 +1254,8 @@ describe("$location", () => {
809
1254
  // let handlerCalled = false;
810
1255
  // $rootScope.$on("$locationChangeSuccess", () => {
811
1256
  // handlerCalled = true;
812
- // if ($location.path() !== "/") {
813
- // $location.path("/").replace();
1257
+ // if ($location.getPath() !== "/") {
1258
+ // $location.setPath("/").replace();
814
1259
  // }
815
1260
  // });
816
1261
  // expect($browser.url()).toEqual("http://server/base/#!/home");
@@ -899,7 +1344,7 @@ describe("$location", () => {
899
1344
  // $rootScope,
900
1345
  // $window,
901
1346
  // ) => {
902
- // $location.url("baz");
1347
+ // $location.setUrl("baz");
903
1348
  // $rootScope.$digest();
904
1349
 
905
1350
  // const originalUrl = $window.location.href;
@@ -911,7 +1356,7 @@ describe("$location", () => {
911
1356
  // });
912
1357
 
913
1358
  // expect($browser.url()).toBe("http://foo.bar/#!/baz/qux");
914
- // expect($location.absUrl()).toBe("http://foo.bar/#!/baz/qux");
1359
+ // expect($location.absUrl).toBe("http://foo.bar/#!/baz/qux");
915
1360
 
916
1361
  // $rootScope.$apply(() => {
917
1362
  // $rootScope.$evalAsync(() => {
@@ -920,7 +1365,7 @@ describe("$location", () => {
920
1365
  // });
921
1366
 
922
1367
  // expect($browser.url()).toBe("http://foo.bar/#!/baz/quux");
923
- // expect($location.absUrl()).toBe("http://foo.bar/#!/baz/quux");
1368
+ // expect($location.absUrl).toBe("http://foo.bar/#!/baz/quux");
924
1369
  // }));
925
1370
 
926
1371
  // it("should correctly update `$location` from URL and not digest infinitely", inject((
@@ -929,7 +1374,7 @@ describe("$location", () => {
929
1374
  // $rootScope,
930
1375
  // $window,
931
1376
  // ) => {
932
- // $location.url("baz");
1377
+ // $location.setUrl("baz");
933
1378
  // $rootScope.$digest();
934
1379
 
935
1380
  // $rootScope.$apply(() => {
@@ -941,16 +1386,16 @@ describe("$location", () => {
941
1386
  // ($window).triggerHandler("hashchange");
942
1387
 
943
1388
  // expect($browser.url()).toBe("http://foo.bar/#!/baz/qux");
944
- // expect($location.absUrl()).toBe("http://foo.bar/#!/baz/qux");
1389
+ // expect($location.absUrl).toBe("http://foo.bar/#!/baz/qux");
945
1390
  // }));
946
1391
  // });
947
1392
 
948
1393
  // function updatePathOnLocationChangeSuccessTo(newPath, newParams) {
949
1394
  // inject(($rootScope, $location) => {
950
1395
  // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
951
- // $location.path(newPath);
1396
+ // $location.setPath(newPath);
952
1397
  // if (newParams) {
953
- // $location.search(newParams);
1398
+ // $location.setSearch(newParams);
954
1399
  // }
955
1400
  // });
956
1401
  // });
@@ -971,7 +1416,7 @@ describe("$location", () => {
971
1416
  // $rootScope.$digest();
972
1417
 
973
1418
  // expect($browser.url()).toEqual("http://server/app/#!/Home");
974
- // expect($location.path()).toEqual("/Home");
1419
+ // expect($location.getPath()).toEqual("/Home");
975
1420
  // expect($browserUrl).toHaveBeenCalledTimes(1);
976
1421
  // });
977
1422
  // });
@@ -993,7 +1438,7 @@ describe("$location", () => {
993
1438
  // $rootScope.$digest();
994
1439
 
995
1440
  // expect($browser.url()).toEqual("http://server/app/#!/");
996
- // expect($location.path()).toEqual("/");
1441
+ // expect($location.getPath()).toEqual("/");
997
1442
  // expect($browserUrl).toHaveBeenCalledTimes(1);
998
1443
  // expect($browserUrl.calls.argsFor(0)).toEqual([
999
1444
  // "http://server/app/#!/",
@@ -1016,7 +1461,7 @@ describe("$location", () => {
1016
1461
  // $rootScope.$digest();
1017
1462
 
1018
1463
  // expect($browser.url()).toEqual("http://server/app/#!/Home");
1019
- // expect($location.path()).toEqual("/Home");
1464
+ // expect($location.getPath()).toEqual("/Home");
1020
1465
  // expect($browserUrl).toHaveBeenCalledTimes(1);
1021
1466
  // expect($browserUrl.calls.argsFor(0)).toEqual([
1022
1467
  // "http://server/app/#!/Home",
@@ -1039,7 +1484,7 @@ describe("$location", () => {
1039
1484
  // $rootScope.$digest();
1040
1485
 
1041
1486
  // expect($browser.url()).toEqual("http://server/app/#!/");
1042
- // expect($location.path()).toEqual("/");
1487
+ // expect($location.getPath()).toEqual("/");
1043
1488
  // expect($browserUrl).toHaveBeenCalledTimes(1);
1044
1489
  // });
1045
1490
  // });
@@ -1061,7 +1506,7 @@ describe("$location", () => {
1061
1506
  // $rootScope.$digest();
1062
1507
 
1063
1508
  // expect($browser.url()).toEqual("http://server/app/Home");
1064
- // expect($location.path()).toEqual("/Home");
1509
+ // expect($location.getPath()).toEqual("/Home");
1065
1510
  // expect($browserUrl).toHaveBeenCalledTimes(1);
1066
1511
  // });
1067
1512
  // });
@@ -1081,7 +1526,7 @@ describe("$location", () => {
1081
1526
  // $rootScope.$digest();
1082
1527
 
1083
1528
  // expect($browser.url()).toEqual("http://server/app/");
1084
- // expect($location.path()).toEqual("/");
1529
+ // expect($location.getPath()).toEqual("/");
1085
1530
  // expect($browserUrl).not.toHaveBeenCalled();
1086
1531
  // });
1087
1532
  // });
@@ -1101,7 +1546,7 @@ describe("$location", () => {
1101
1546
  // $rootScope.$digest();
1102
1547
 
1103
1548
  // expect($browser.url()).toEqual("http://server/app/Home");
1104
- // expect($location.path()).toEqual("/Home");
1549
+ // expect($location.getPath()).toEqual("/Home");
1105
1550
  // expect($browserUrl).toHaveBeenCalledTimes(1);
1106
1551
  // });
1107
1552
  // });
@@ -1121,7 +1566,7 @@ describe("$location", () => {
1121
1566
  // $rootScope.$digest();
1122
1567
 
1123
1568
  // expect($browser.url()).toEqual("http://server/app/");
1124
- // expect($location.path()).toEqual("/");
1569
+ // expect($location.getPath()).toEqual("/");
1125
1570
  // expect($browserUrl).not.toHaveBeenCalled();
1126
1571
  // });
1127
1572
  // });
@@ -1141,8 +1586,8 @@ describe("$location", () => {
1141
1586
 
1142
1587
  // $rootScope.$digest();
1143
1588
 
1144
- // expect($location.path()).toEqual("/");
1145
- // expect($location.search()).toEqual({ q: "'" });
1589
+ // expect($location.getPath()).toEqual("/");
1590
+ // expect($location.getSearch()).toEqual({ q: "'" });
1146
1591
  // expect($browserUrl).toHaveBeenCalledTimes(1);
1147
1592
  // });
1148
1593
  // });
@@ -1154,12 +1599,12 @@ describe("$location", () => {
1154
1599
  // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1155
1600
  // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1156
1601
  // inject(($window, $browser, $location, $rootScope) => {
1157
- // spyOn($location, "$$parse").and.callThrough();
1602
+ // spyOn($location, "parse").and.callThrough();
1158
1603
  // $window.location.href = "http://new.com/a/b#!/aaa";
1159
1604
  // $browser.$$checkUrlChange();
1160
- // expect($location.absUrl()).toBe("http://new.com/a/b#!/aaa");
1161
- // expect($location.path()).toBe("/aaa");
1162
- // expect($location.$$parse).toHaveBeenCalled();
1605
+ // expect($location.absUrl).toBe("http://new.com/a/b#!/aaa");
1606
+ // expect($location.getPath()).toBe("/aaa");
1607
+ // expect($location.parse).toHaveBeenCalled();
1163
1608
  // });
1164
1609
  // });
1165
1610
 
@@ -1174,10 +1619,10 @@ describe("$location", () => {
1174
1619
  // $rootScope.$apply(() => {
1175
1620
  // $window.location.href = NEW_URL;
1176
1621
  // $browser.$$checkUrlChange(); // simulate firing event from browser
1177
- // expect($location.absUrl()).toBe(OLD_URL); // should be async
1622
+ // expect($location.absUrl).toBe(OLD_URL); // should be async
1178
1623
  // });
1179
1624
 
1180
- // expect($location.absUrl()).toBe(NEW_URL);
1625
+ // expect($location.absUrl).toBe(NEW_URL);
1181
1626
  // });
1182
1627
  // });
1183
1628
 
@@ -1195,12 +1640,12 @@ describe("$location", () => {
1195
1640
  // notRunYet = false;
1196
1641
  // $window.location.href = NEW_URL;
1197
1642
  // $browser.$$checkUrlChange(); // simulate firing event from browser
1198
- // expect($location.absUrl()).toBe(OLD_URL); // should be async
1643
+ // expect($location.absUrl).toBe(OLD_URL); // should be async
1199
1644
  // }
1200
1645
  // });
1201
1646
 
1202
1647
  // $rootScope.$digest();
1203
- // expect($location.absUrl()).toBe(NEW_URL);
1648
+ // expect($location.absUrl).toBe(NEW_URL);
1204
1649
  // });
1205
1650
  // });
1206
1651
 
@@ -1212,7 +1657,7 @@ describe("$location", () => {
1212
1657
  // $browser,
1213
1658
  // "url",
1214
1659
  // ).and.callThrough();
1215
- // $location.path("/new/path");
1660
+ // $location.setPath("/new/path");
1216
1661
  // expect($browserUrl).not.toHaveBeenCalled();
1217
1662
  // $rootScope.$apply();
1218
1663
 
@@ -1229,10 +1674,10 @@ describe("$location", () => {
1229
1674
  // $browser,
1230
1675
  // "url",
1231
1676
  // ).and.callThrough();
1232
- // $location.path("/new/path");
1677
+ // $location.setPath("/new/path");
1233
1678
 
1234
1679
  // $rootScope.$watch(() => {
1235
- // $location.search("a=b");
1680
+ // $location.setSearch("a=b");
1236
1681
  // });
1237
1682
 
1238
1683
  // $rootScope.$apply();
@@ -1249,7 +1694,7 @@ describe("$location", () => {
1249
1694
  // $browser,
1250
1695
  // "url",
1251
1696
  // ).and.callThrough();
1252
- // $location.path("/n/url").replace();
1697
+ // $location.setPath("/n/url").replace();
1253
1698
  // $rootScope.$apply();
1254
1699
 
1255
1700
  // expect($browserUrl).toHaveBeenCalled();
@@ -1267,16 +1712,16 @@ describe("$location", () => {
1267
1712
  // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1268
1713
  // inject(($rootScope, $browser, $location) => {
1269
1714
  // // init watches
1270
- // $location.url("/initUrl");
1715
+ // $location.setUrl("/initUrl");
1271
1716
  // $rootScope.$apply();
1272
1717
 
1273
1718
  // // changes url but resets it before digest
1274
- // $location.url("/newUrl").replace().url("/initUrl");
1719
+ // $location.setUrl("/newUrl").replace().url("/initUrl");
1275
1720
  // $rootScope.$apply();
1276
1721
  // expect($location.$$replace).toBe(false);
1277
1722
 
1278
1723
  // // set the url to the old value
1279
- // $location.url("/newUrl").replace();
1724
+ // $location.setUrl("/newUrl").replace();
1280
1725
  // $rootScope.$apply();
1281
1726
  // expect($location.$$replace).toBe(false);
1282
1727
 
@@ -1294,7 +1739,7 @@ describe("$location", () => {
1294
1739
  // $rootScope.$watch(
1295
1740
  // () => true,
1296
1741
  // () => {
1297
- // $location.path("/changed");
1742
+ // $location.setPath("/changed");
1298
1743
  // },
1299
1744
  // );
1300
1745
 
@@ -1307,7 +1752,7 @@ describe("$location", () => {
1307
1752
  // initService({ html5Mode: false, hashPrefix: "", supportHistory: true });
1308
1753
  // mockUpBrowser({ initialUrl: "http://new.com/a/b", baseHref: "/a/b" });
1309
1754
  // inject(($rootScope, $browser, $location) => {
1310
- // $location.hash("test");
1755
+ // $location.setHash("test");
1311
1756
 
1312
1757
  // $rootScope.$digest();
1313
1758
  // expect($browser.url()).toBe("http://new.com/a/b##test");
@@ -1324,7 +1769,7 @@ describe("$location", () => {
1324
1769
  // state: { a: 2 },
1325
1770
  // });
1326
1771
  // inject(($location) => {
1327
- // expect($location.state()).toEqual({ a: 2 });
1772
+ // expect($location.getState()).toEqual({ a: 2 });
1328
1773
  // });
1329
1774
  // });
1330
1775
 
@@ -1335,7 +1780,7 @@ describe("$location", () => {
1335
1780
  // $window.history.pushState({ b: 3 });
1336
1781
  // $rootScope.$digest();
1337
1782
 
1338
- // expect($location.state()).toEqual({ b: 3 });
1783
+ // expect($location.getState()).toEqual({ b: 3 });
1339
1784
 
1340
1785
  // $window.history.pushState(
1341
1786
  // { b: 4 },
@@ -1344,10 +1789,10 @@ describe("$location", () => {
1344
1789
  // );
1345
1790
  // $rootScope.$digest();
1346
1791
 
1347
- // expect($location.path()).toBe("/c");
1348
- // expect($location.search()).toEqual({ d: "e" });
1349
- // expect($location.hash()).toBe("f");
1350
- // expect($location.state()).toEqual({ b: 4 });
1792
+ // expect($location.getPath()).toBe("/c");
1793
+ // expect($location.getSearch()).toEqual({ d: "e" });
1794
+ // expect($location.getHash()).toBe("f");
1795
+ // expect($location.getState()).toEqual({ b: 4 });
1351
1796
  // });
1352
1797
  // });
1353
1798
 
@@ -1362,9 +1807,9 @@ describe("$location", () => {
1362
1807
  // $window.history.pushState({}, null, "http://server/app/Home?q='");
1363
1808
  // $rootScope.$digest();
1364
1809
 
1365
- // expect($location.absUrl()).toEqual("http://server/app/Home?q='");
1366
- // expect($location.path()).toEqual("/Home");
1367
- // expect($location.search()).toEqual({ q: "'" });
1810
+ // expect($location.absUrl).toEqual("http://server/app/Home?q='");
1811
+ // expect($location.getPath()).toEqual("/Home");
1812
+ // expect($location.getSearch()).toEqual({ q: "'" });
1368
1813
  // });
1369
1814
  // });
1370
1815
 
@@ -1379,9 +1824,9 @@ describe("$location", () => {
1379
1824
  // $window.location.href = "http://server/app/Home?q='";
1380
1825
  // ($window).triggerHandler("popstate");
1381
1826
 
1382
- // expect($location.absUrl()).toEqual("http://server/app/Home?q='");
1383
- // expect($location.path()).toEqual("/Home");
1384
- // expect($location.search()).toEqual({ q: "'" });
1827
+ // expect($location.absUrl).toEqual("http://server/app/Home?q='");
1828
+ // expect($location.getPath()).toEqual("/Home");
1829
+ // expect($location.getSearch()).toEqual({ q: "'" });
1385
1830
  // });
1386
1831
  // });
1387
1832
 
@@ -1393,7 +1838,7 @@ describe("$location", () => {
1393
1838
  // $browser,
1394
1839
  // "url",
1395
1840
  // ).and.callThrough();
1396
- // $location.path("/n/url").state({ a: 2 }).replace();
1841
+ // $location.setPath("/n/url").state({ a: 2 }).replace();
1397
1842
  // $rootScope.$apply();
1398
1843
 
1399
1844
  // expect($browserUrl).toHaveBeenCalled();
@@ -1417,11 +1862,11 @@ describe("$location", () => {
1417
1862
  // "url",
1418
1863
  // ).and.callThrough();
1419
1864
  // $location
1420
- // .path("/n/url")
1865
+ // .setPath("/n/url")
1421
1866
  // .state({ a: 2 })
1422
1867
  // .replace()
1423
1868
  // .state({ b: 3 })
1424
- // .path("/o/url");
1869
+ // .setPath("/o/url");
1425
1870
  // $rootScope.$apply();
1426
1871
 
1427
1872
  // expect($browserUrl).toHaveBeenCalled();
@@ -1444,7 +1889,7 @@ describe("$location", () => {
1444
1889
  // $browser,
1445
1890
  // "url",
1446
1891
  // ).and.callThrough();
1447
- // $location.state({ a: 2 }).replace().state({ b: 3 });
1892
+ // $location.setState({ a: 2 }).replace().state({ b: 3 });
1448
1893
  // $rootScope.$apply();
1449
1894
 
1450
1895
  // expect($browserUrl).toHaveBeenCalled();
@@ -1464,7 +1909,7 @@ describe("$location", () => {
1464
1909
 
1465
1910
  // inject(($rootScope, $location) => {
1466
1911
  // // init watches
1467
- // $location.url("/initUrl").state({ a: 2 });
1912
+ // $location.setUrl("/initUrl").state({ a: 2 });
1468
1913
  // $rootScope.$apply();
1469
1914
 
1470
1915
  // // changes url & state but resets them before digest
@@ -1478,7 +1923,7 @@ describe("$location", () => {
1478
1923
  // expect($location.$$replace).toBe(false);
1479
1924
 
1480
1925
  // // set the url to the old value
1481
- // $location.url("/newUrl").state({ a: 2 }).replace();
1926
+ // $location.setUrl("/newUrl").state({ a: 2 }).replace();
1482
1927
  // $rootScope.$apply();
1483
1928
  // expect($location.$$replace).toBe(false);
1484
1929
 
@@ -1495,7 +1940,7 @@ describe("$location", () => {
1495
1940
 
1496
1941
  // inject(($rootScope, $location, $browser) => {
1497
1942
  // const o = { a: 2 };
1498
- // $location.state(o);
1943
+ // $location.setState(o);
1499
1944
  // o.a = 3;
1500
1945
  // $rootScope.$apply();
1501
1946
  // expect($browser.state()).toEqual({ a: 3 });
@@ -1506,14 +1951,14 @@ describe("$location", () => {
1506
1951
  // });
1507
1952
  // });
1508
1953
 
1509
- // it("should make $location.state() referencially identical with $browser.state() after digest", () => {
1954
+ // it("should make $location.getState() referencially identical with $browser.state() after digest", () => {
1510
1955
  // initService({ html5Mode: true, supportHistory: true });
1511
1956
  // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1512
1957
 
1513
1958
  // inject(($rootScope, $location, $browser) => {
1514
- // $location.state({ a: 2 });
1959
+ // $location.setState({ a: 2 });
1515
1960
  // $rootScope.$apply();
1516
- // expect($location.state()).toBe($browser.state());
1961
+ // expect($location.getState()).toBe($browser.state());
1517
1962
  // });
1518
1963
  // });
1519
1964
 
@@ -1522,9 +1967,9 @@ describe("$location", () => {
1522
1967
  // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1523
1968
 
1524
1969
  // inject(($rootScope, $location) => {
1525
- // $location.url("/foo").state({ a: 2 });
1970
+ // $location.setUrl("/foo").state({ a: 2 });
1526
1971
  // $rootScope.$apply();
1527
- // expect($location.state()).toEqual({ a: 2 });
1972
+ // expect($location.getState()).toEqual({ a: 2 });
1528
1973
  // });
1529
1974
  // });
1530
1975
 
@@ -1533,14 +1978,14 @@ describe("$location", () => {
1533
1978
  // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1534
1979
 
1535
1980
  // inject(($rootScope, $location, $browser) => {
1536
- // $location.url("/foo").state({ a: 2 });
1981
+ // $location.setUrl("/foo").state({ a: 2 });
1537
1982
  // $rootScope.$apply();
1538
1983
 
1539
1984
  // const $browserUrl = spyOnlyCallsWithArgs(
1540
1985
  // $browser,
1541
1986
  // "url",
1542
1987
  // ).and.callThrough();
1543
- // $location.url("/bar");
1988
+ // $location.setUrl("/bar");
1544
1989
  // $rootScope.$apply();
1545
1990
 
1546
1991
  // expect($browserUrl).toHaveBeenCalled();
@@ -1579,8 +2024,8 @@ describe("$location", () => {
1579
2024
  // });
1580
2025
  // inject(($rootScope, $location, $browser) => {
1581
2026
  // expect($browser.url()).toBe("http://domain.com/base/index.html#!/a/b");
1582
- // $location.path("/new");
1583
- // $location.search({ a: true });
2027
+ // $location.setPath("/new");
2028
+ // $location.setSearch({ a: true });
1584
2029
  // $rootScope.$apply();
1585
2030
  // expect($browser.url()).toBe(
1586
2031
  // "http://domain.com/base/index.html#!/new?a",
@@ -1596,8 +2041,8 @@ describe("$location", () => {
1596
2041
  // });
1597
2042
  // inject(($rootScope, $location, $browser) => {
1598
2043
  // expect($browser.url()).toBe("http://domain.com/base/index.html#/a/b");
1599
- // $location.path("/new");
1600
- // $location.search({ a: true });
2044
+ // $location.setPath("/new");
2045
+ // $location.setSearch({ a: true });
1601
2046
  // $rootScope.$apply();
1602
2047
  // expect($browser.url()).toBe("http://domain.com/base/index.html#/new?a");
1603
2048
  // });
@@ -1618,8 +2063,8 @@ describe("$location", () => {
1618
2063
  // expect($browser.url()).toBe(
1619
2064
  // "http://domain.com/base/index.html#!!/a/b",
1620
2065
  // );
1621
- // $location.path("/new");
1622
- // $location.search({ a: true });
2066
+ // $location.setPath("/new");
2067
+ // $location.setSearch({ a: true });
1623
2068
  // $rootScope.$apply();
1624
2069
  // expect($browser.url()).toBe(
1625
2070
  // "http://domain.com/base/index.html#!!/new?a",
@@ -1670,8 +2115,8 @@ describe("$location", () => {
1670
2115
  // });
1671
2116
  // inject(($rootScope, $location, $browser) => {
1672
2117
  // expect($browser.url()).toBe("http://domain.com/base/old/index.html#a");
1673
- // $location.path("/new");
1674
- // $location.search({ a: true });
2118
+ // $location.setPath("/new");
2119
+ // $location.setSearch({ a: true });
1675
2120
  // $rootScope.$apply();
1676
2121
  // expect($browser.url()).toBe("http://domain.com/base/new?a#a");
1677
2122
  // });
@@ -1685,11 +2130,11 @@ describe("$location", () => {
1685
2130
  // });
1686
2131
  // inject(($rootScope, $location, $browser) => {
1687
2132
  // expect($browser.url()).toBe("http://domain.com/base/a/b");
1688
- // $location.path("/new");
1689
- // $location.hash("abc");
2133
+ // $location.setPath("/new");
2134
+ // $location.setHash("abc");
1690
2135
  // $rootScope.$apply();
1691
2136
  // expect($browser.url()).toBe("http://domain.com/base/new#abc");
1692
- // expect($location.path()).toBe("/new");
2137
+ // expect($location.getPath()).toBe("/new");
1693
2138
  // });
1694
2139
  // });
1695
2140
 
@@ -1701,7 +2146,7 @@ describe("$location", () => {
1701
2146
  // });
1702
2147
  // inject(($rootScope, $location, $browser) => {
1703
2148
  // expect($browser.url()).toBe("http://domain.com/base/a/b");
1704
- // expect($location.path()).toBe("/a/b");
2149
+ // expect($location.getPath()).toBe("/a/b");
1705
2150
  // });
1706
2151
  // });
1707
2152
  // });
@@ -1898,7 +2343,7 @@ describe("$location", () => {
1898
2343
  // );
1899
2344
  // });
1900
2345
 
1901
- // it('should produce relative paths correctly when $location.path() is "/" when history enabled on old browser', () => {
2346
+ // it('should produce relative paths correctly when $location.getPath() is "/" when history enabled on old browser', () => {
1902
2347
  // configureTestLink({ linkHref: "partial1" });
1903
2348
  // initService({ html5Mode: true, supportHistory: false, hashPrefix: "!" });
1904
2349
  // inject(
@@ -1909,7 +2354,7 @@ describe("$location", () => {
1909
2354
  // setupRewriteChecks(),
1910
2355
  // ($browser, $location, $rootScope) => {
1911
2356
  // $rootScope.$apply(() => {
1912
- // $location.path("/");
2357
+ // $location.setPath("/");
1913
2358
  // });
1914
2359
  // browserTrigger(link, "click");
1915
2360
  // expectRewriteTo(
@@ -2226,11 +2671,11 @@ describe("$location", () => {
2226
2671
  // setupRewriteChecks(),
2227
2672
  // ($browser, $location, $rootScope) => {
2228
2673
  // $rootScope.$apply(() => {
2229
- // $location.path("/some");
2230
- // $location.hash("foo");
2674
+ // $location.setPath("/some");
2675
+ // $location.setHash("foo");
2231
2676
  // });
2232
2677
  // browserTrigger(link, "click");
2233
- // expect($location.hash()).toBe("link");
2678
+ // expect($location.getHash()).toBe("link");
2234
2679
  // expectRewriteTo(
2235
2680
  // $browser,
2236
2681
  // "http://host.com/base/index.html#!/some#link",
@@ -2250,11 +2695,11 @@ describe("$location", () => {
2250
2695
  // setupRewriteChecks(),
2251
2696
  // ($browser, $location, $rootScope) => {
2252
2697
  // $rootScope.$apply(() => {
2253
- // $location.path("/some");
2254
- // $location.hash("foo");
2698
+ // $location.setPath("/some");
2699
+ // $location.setHash("foo");
2255
2700
  // });
2256
2701
  // browserTrigger(link, "click");
2257
- // expect($location.hash()).toBe("link");
2702
+ // expect($location.getHash()).toBe("link");
2258
2703
  // expectRewriteTo($browser, "http://host.com/base/some#link");
2259
2704
  // },
2260
2705
  // );
@@ -2566,9 +3011,9 @@ describe("$location", () => {
2566
3011
  // $log.info("after", newUrl, oldUrl, $browser.url());
2567
3012
  // });
2568
3013
 
2569
- // expect($location.url()).toEqual("");
2570
- // $location.url("/somePath");
2571
- // expect($location.url()).toEqual("/somePath");
3014
+ // expect($location.getUrl()).toEqual("");
3015
+ // $location.setUrl("/somePath");
3016
+ // expect($location.getUrl()).toEqual("/somePath");
2572
3017
  // expect($browser.url()).toEqual("http://server/");
2573
3018
  // expect($log.info.logs).toEqual([]);
2574
3019
 
@@ -2586,7 +3031,7 @@ describe("$location", () => {
2586
3031
  // "http://server/",
2587
3032
  // "http://server/#!/somePath",
2588
3033
  // ]);
2589
- // expect($location.url()).toEqual("/somePath");
3034
+ // expect($location.getUrl()).toEqual("/somePath");
2590
3035
  // expect($browser.url()).toEqual("http://server/#!/somePath");
2591
3036
  // }));
2592
3037
 
@@ -2597,7 +3042,7 @@ describe("$location", () => {
2597
3042
  // $log,
2598
3043
  // ) => {
2599
3044
  // expect($browser.url()).toEqual("http://server/");
2600
- // expect($location.url()).toEqual("");
3045
+ // expect($location.getUrl()).toEqual("");
2601
3046
 
2602
3047
  // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
2603
3048
  // $log.info("before", newUrl, oldUrl, $browser.url());
@@ -2607,9 +3052,9 @@ describe("$location", () => {
2607
3052
  // throw new Error("location should have been canceled");
2608
3053
  // });
2609
3054
 
2610
- // expect($location.url()).toEqual("");
2611
- // $location.url("/somePath");
2612
- // expect($location.url()).toEqual("/somePath");
3055
+ // expect($location.getUrl()).toEqual("");
3056
+ // $location.setUrl("/somePath");
3057
+ // expect($location.getUrl()).toEqual("/somePath");
2613
3058
  // expect($browser.url()).toEqual("http://server/");
2614
3059
  // expect($log.info.logs).toEqual([]);
2615
3060
 
@@ -2622,7 +3067,7 @@ describe("$location", () => {
2622
3067
  // "http://server/",
2623
3068
  // ]);
2624
3069
  // expect($log.info.logs[1]).toBeUndefined();
2625
- // expect($location.url()).toEqual("");
3070
+ // expect($location.getUrl()).toEqual("");
2626
3071
  // expect($browser.url()).toEqual("http://server/");
2627
3072
  // }));
2628
3073
 
@@ -2635,14 +3080,14 @@ describe("$location", () => {
2635
3080
  // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
2636
3081
  // $log.info("before", newUrl, oldUrl, $browser.url());
2637
3082
  // if (newUrl === "http://server/#!/somePath") {
2638
- // $location.url("/redirectPath");
3083
+ // $location.setUrl("/redirectPath");
2639
3084
  // }
2640
3085
  // });
2641
3086
  // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
2642
3087
  // $log.info("after", newUrl, oldUrl, $browser.url());
2643
3088
  // });
2644
3089
 
2645
- // $location.url("/somePath");
3090
+ // $location.setUrl("/somePath");
2646
3091
  // $rootScope.$apply();
2647
3092
 
2648
3093
  // expect($log.info.logs.shift()).toEqual([
@@ -2664,7 +3109,7 @@ describe("$location", () => {
2664
3109
  // "http://server/#!/redirectPath",
2665
3110
  // ]);
2666
3111
 
2667
- // expect($location.url()).toEqual("/redirectPath");
3112
+ // expect($location.getUrl()).toEqual("/redirectPath");
2668
3113
  // expect($browser.url()).toEqual("http://server/#!/redirectPath");
2669
3114
  // }));
2670
3115
 
@@ -2678,14 +3123,14 @@ describe("$location", () => {
2678
3123
  // $log.info("before", newUrl, oldUrl, $browser.url());
2679
3124
  // if (newUrl === "http://server/#!/somePath") {
2680
3125
  // event.preventDefault();
2681
- // $location.url("/redirectPath");
3126
+ // $location.setUrl("/redirectPath");
2682
3127
  // }
2683
3128
  // });
2684
3129
  // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
2685
3130
  // $log.info("after", newUrl, oldUrl, $browser.url());
2686
3131
  // });
2687
3132
 
2688
- // $location.url("/somePath");
3133
+ // $location.setUrl("/somePath");
2689
3134
  // $rootScope.$apply();
2690
3135
 
2691
3136
  // expect($log.info.logs.shift()).toEqual([
@@ -2707,7 +3152,7 @@ describe("$location", () => {
2707
3152
  // "http://server/#!/redirectPath",
2708
3153
  // ]);
2709
3154
 
2710
- // expect($location.url()).toEqual("/redirectPath");
3155
+ // expect($location.getUrl()).toEqual("/redirectPath");
2711
3156
  // expect($browser.url()).toEqual("http://server/#!/redirectPath");
2712
3157
  // }));
2713
3158
 
@@ -2720,16 +3165,16 @@ describe("$location", () => {
2720
3165
  // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
2721
3166
  // $log.info("before", newUrl, oldUrl, $browser.url());
2722
3167
  // if (newUrl === "http://server/#!/somePath") {
2723
- // $location.url("/redirectPath");
3168
+ // $location.setUrl("/redirectPath");
2724
3169
  // } else if (newUrl === "http://server/#!/redirectPath") {
2725
- // $location.url("/redirectPath2");
3170
+ // $location.setUrl("/redirectPath2");
2726
3171
  // }
2727
3172
  // });
2728
3173
  // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
2729
3174
  // $log.info("after", newUrl, oldUrl, $browser.url());
2730
3175
  // });
2731
3176
 
2732
- // $location.url("/somePath");
3177
+ // $location.setUrl("/somePath");
2733
3178
  // $rootScope.$apply();
2734
3179
 
2735
3180
  // expect($log.info.logs.shift()).toEqual([
@@ -2757,7 +3202,7 @@ describe("$location", () => {
2757
3202
  // "http://server/#!/redirectPath2",
2758
3203
  // ]);
2759
3204
 
2760
- // expect($location.url()).toEqual("/redirectPath2");
3205
+ // expect($location.getUrl()).toEqual("/redirectPath2");
2761
3206
  // expect($browser.url()).toEqual("http://server/#!/redirectPath2");
2762
3207
  // }));
2763
3208
 
@@ -2770,7 +3215,7 @@ describe("$location", () => {
2770
3215
  // $rootScope.$apply(); // clear initial $locationChangeStart
2771
3216
 
2772
3217
  // expect($browser.url()).toEqual("http://server/");
2773
- // expect($location.url()).toEqual("");
3218
+ // expect($location.getUrl()).toEqual("");
2774
3219
 
2775
3220
  // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
2776
3221
  // $log.info("start", newUrl, oldUrl);
@@ -2800,11 +3245,11 @@ describe("$location", () => {
2800
3245
  // $rootScope,
2801
3246
  // $log,
2802
3247
  // ) => {
2803
- // $location.url("/somepath");
3248
+ // $location.setUrl("/somepath");
2804
3249
  // $rootScope.$apply();
2805
3250
 
2806
3251
  // expect($browser.url()).toEqual("http://server/#!/somepath");
2807
- // expect($location.url()).toEqual("/somepath");
3252
+ // expect($location.getUrl()).toEqual("/somepath");
2808
3253
 
2809
3254
  // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
2810
3255
  // $log.info("start", newUrl, oldUrl);
@@ -2837,7 +3282,7 @@ describe("$location", () => {
2837
3282
  // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
2838
3283
  // $log.info("before", newUrl, oldUrl, $browser.url());
2839
3284
  // if (newUrl === "http://server/#!/somePath") {
2840
- // $location.url("/redirectPath");
3285
+ // $location.setUrl("/redirectPath");
2841
3286
  // }
2842
3287
  // });
2843
3288
  // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
@@ -2866,7 +3311,7 @@ describe("$location", () => {
2866
3311
  // "http://server/#!/redirectPath",
2867
3312
  // ]);
2868
3313
 
2869
- // expect($location.url()).toEqual("/redirectPath");
3314
+ // expect($location.getUrl()).toEqual("/redirectPath");
2870
3315
  // expect($browser.url()).toEqual("http://server/#!/redirectPath");
2871
3316
  // }));
2872
3317
 
@@ -2880,7 +3325,7 @@ describe("$location", () => {
2880
3325
  // $log.info("before", newUrl, oldUrl, $browser.url());
2881
3326
  // if (newUrl === "http://server/#!/somePath") {
2882
3327
  // event.preventDefault();
2883
- // $location.url("/redirectPath");
3328
+ // $location.setUrl("/redirectPath");
2884
3329
  // }
2885
3330
  // });
2886
3331
  // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
@@ -2909,7 +3354,7 @@ describe("$location", () => {
2909
3354
  // "http://server/#!/redirectPath",
2910
3355
  // ]);
2911
3356
 
2912
- // expect($location.url()).toEqual("/redirectPath");
3357
+ // expect($location.getUrl()).toEqual("/redirectPath");
2913
3358
  // expect($browser.url()).toEqual("http://server/#!/redirectPath");
2914
3359
  // }));
2915
3360
 
@@ -2985,17 +3430,17 @@ describe("$location", () => {
2985
3430
  // const base = $browser.url();
2986
3431
 
2987
3432
  // $rootScope.$on("$locationChangeStart", () => {
2988
- // log($location.path());
3433
+ // log($location.getPath());
2989
3434
  // });
2990
3435
 
2991
3436
  // // change through $location service
2992
3437
  // $rootScope.$apply(() => {
2993
- // $location.path("/myNewPath");
3438
+ // $location.setPath("/myNewPath");
2994
3439
  // });
2995
3440
 
2996
3441
  // // reset location
2997
3442
  // $rootScope.$apply(() => {
2998
- // $location.path("");
3443
+ // $location.setPath("");
2999
3444
  // });
3000
3445
 
3001
3446
  // // change through $browser
@@ -3007,100 +3452,32 @@ describe("$location", () => {
3007
3452
  // });
3008
3453
 
3009
3454
  describe("$locationProvider", () => {
3010
- describe("html5Mode", () => {
3011
- it("should set enabled, requireBase and rewriteLinks when called with object", () => {
3455
+ describe("html5ModeConf", () => {
3456
+ it("should have default values", () => {
3012
3457
  module.config(($locationProvider) => {
3013
- $locationProvider.setHtml5Mode({
3458
+ expect($locationProvider.html5ModeConf).toEqual({
3014
3459
  enabled: true,
3015
3460
  requireBase: false,
3016
- rewriteLinks: false,
3017
- });
3018
- expect($locationProvider.getHtml5Mode()).toEqual({
3019
- enabled: true,
3020
- requireBase: false,
3021
- rewriteLinks: false,
3022
- });
3023
- });
3024
- createInjector(["test1"]);
3025
- });
3026
-
3027
- it("should only overwrite existing properties if values are of the correct type", () => {
3028
- module.config(($locationProvider) => {
3029
- $locationProvider.setHtml5Mode({
3030
- enabled: "duh",
3031
- requireBase: "probably",
3032
- rewriteLinks: 0,
3033
- });
3034
-
3035
- expect($locationProvider.getHtml5Mode()).toEqual({
3036
- enabled: false,
3037
- requireBase: true,
3038
3461
  rewriteLinks: true,
3039
3462
  });
3040
3463
  });
3041
-
3042
- createInjector(["test1"]);
3043
- });
3044
-
3045
- it("should support setting rewriteLinks to a string", () => {
3046
- module.config(($locationProvider) => {
3047
- $locationProvider.setHtml5Mode({
3048
- rewriteLinks: "yes-rewrite",
3049
- });
3050
-
3051
- expect($locationProvider.getHtml5Mode().rewriteLinks).toEqual(
3052
- "yes-rewrite",
3053
- );
3054
- });
3055
-
3056
- createInjector(["test1"]);
3057
- });
3058
-
3059
- it("should not set unknown input properties to html5Mode object", () => {
3060
- module.config(($locationProvider) => {
3061
- $locationProvider.setHtml5Mode({
3062
- someProp: "foo",
3063
- });
3064
-
3065
- expect($locationProvider.getHtml5Mode()).toEqual({
3066
- enabled: false,
3067
- requireBase: true,
3068
- rewriteLinks: true,
3069
- });
3070
- });
3071
-
3072
- createInjector(["test1"]);
3073
- });
3074
-
3075
- it("should default to enabled:false, requireBase:true and rewriteLinks:true", () => {
3076
- module.config(($locationProvider) => {
3077
- expect($locationProvider.getHtml5Mode()).toEqual({
3078
- enabled: false,
3079
- requireBase: true,
3080
- rewriteLinks: true,
3081
- });
3082
- });
3083
-
3084
3464
  createInjector(["test1"]);
3085
3465
  });
3086
3466
  });
3087
3467
  });
3088
3468
 
3089
- describe("LocationHtml5Url", () => {
3469
+ describe("Location with html5 url", () => {
3090
3470
  let locationUrl;
3091
3471
  let locationUmlautUrl;
3092
3472
  let locationIndexUrl;
3093
3473
 
3094
3474
  beforeEach(() => {
3095
- locationUrl = new LocationHtml5Url(
3096
- "http://server/pre/",
3097
- "http://server/pre/",
3098
- );
3099
- locationUmlautUrl = new LocationHtml5Url(
3475
+ locationUrl = new Location("http://server/pre/", "http://server/pre/");
3476
+ locationUmlautUrl = new Location(
3100
3477
  "http://särver/pre/",
3101
3478
  "http://särver/pre/",
3102
3479
  );
3103
- locationIndexUrl = new LocationHtml5Url(
3480
+ locationIndexUrl = new Location(
3104
3481
  "http://server/pre/index.html",
3105
3482
  "http://server/pre/",
3106
3483
  );
@@ -3209,17 +3586,18 @@ describe("$location", () => {
3209
3586
  // });
3210
3587
 
3211
3588
  it("should support state", () => {
3212
- expect(locationUrl.state({ a: 2 }).state()).toEqual({ a: 2 });
3589
+ expect(locationUrl.setState({ a: 2 }).getState()).toEqual({ a: 2 });
3213
3590
  });
3214
3591
  });
3215
3592
 
3216
- describe("LocationHashbangUrl", () => {
3593
+ describe("Location with hashbang url", () => {
3217
3594
  let locationUrl;
3218
3595
 
3219
3596
  it("should rewrite URL", () => {
3220
- locationUrl = new LocationHashbangUrl(
3597
+ locationUrl = new Location(
3221
3598
  "http://server/pre/",
3222
3599
  "http://server/pre/",
3600
+ false,
3223
3601
  "#",
3224
3602
  );
3225
3603
 
@@ -3239,73 +3617,74 @@ describe("$location", () => {
3239
3617
  });
3240
3618
 
3241
3619
  it("should not set hash if one was not originally specified", () => {
3242
- locationUrl = new LocationHashbangUrl(
3620
+ locationUrl = new Location(
3243
3621
  "http://server/pre/index.html",
3244
3622
  "http://server/pre/",
3623
+ false,
3245
3624
  "#",
3246
3625
  );
3247
3626
 
3248
- locationUrl.$$parse("http://server/pre/index.html");
3249
- expect(locationUrl.url()).toBe("");
3250
- expect(locationUrl.absUrl()).toBe("http://server/pre/index.html");
3627
+ locationUrl.parse("http://server/pre/index.html");
3628
+ expect(locationUrl.getUrl()).toBe("");
3629
+ expect(locationUrl.absUrl).toBe("http://server/pre/index.html");
3251
3630
  });
3252
3631
 
3253
3632
  it("should parse hash if one was specified", () => {
3254
- locationUrl = new LocationHashbangUrl(
3633
+ locationUrl = new Location(
3255
3634
  "http://server/pre/index.html",
3256
3635
  "http://server/pre/",
3636
+ false,
3257
3637
  "#",
3258
3638
  );
3259
3639
 
3260
- locationUrl.$$parse("http://server/pre/index.html#/foo/bar");
3261
- expect(locationUrl.url()).toBe("/foo/bar");
3262
- expect(locationUrl.absUrl()).toBe(
3263
- "http://server/pre/index.html#/foo/bar",
3264
- );
3640
+ locationUrl.parse("http://server/pre/index.html#/foo/bar");
3641
+ expect(locationUrl.getUrl()).toBe("/foo/bar");
3642
+ expect(locationUrl.absUrl).toBe("http://server/pre/index.html#/foo/bar");
3265
3643
  });
3266
3644
 
3267
3645
  it("should prefix hash url with / if one was originally missing", () => {
3268
- locationUrl = new LocationHashbangUrl(
3646
+ locationUrl = new Location(
3269
3647
  "http://server/pre/index.html",
3270
3648
  "http://server/pre/",
3649
+ false,
3271
3650
  "#",
3272
3651
  );
3273
3652
 
3274
- locationUrl.$$parse(
3275
- "http://server/pre/index.html#not-starting-with-slash",
3276
- );
3277
- expect(locationUrl.url()).toBe("/not-starting-with-slash");
3278
- expect(locationUrl.absUrl()).toBe(
3653
+ locationUrl.parse("http://server/pre/index.html#not-starting-with-slash");
3654
+ expect(locationUrl.getUrl()).toBe("/not-starting-with-slash");
3655
+ expect(locationUrl.absUrl).toBe(
3279
3656
  "http://server/pre/index.html#/not-starting-with-slash",
3280
3657
  );
3281
3658
  });
3282
3659
 
3283
3660
  it("should not strip stuff from path just because it looks like Windows drive when it's not", () => {
3284
- locationUrl = new LocationHashbangUrl(
3661
+ locationUrl = new Location(
3285
3662
  "http://server/pre/index.html",
3286
3663
  "http://server/pre/",
3664
+ false,
3287
3665
  "#",
3288
3666
  );
3289
3667
 
3290
- locationUrl.$$parse(
3668
+ locationUrl.parse(
3291
3669
  "http://server/pre/index.html#http%3A%2F%2Fexample.com%2F",
3292
3670
  );
3293
- expect(locationUrl.url()).toBe("/http://example.com/");
3294
- expect(locationUrl.absUrl()).toBe(
3671
+ expect(locationUrl.getUrl()).toBe("/http://example.com/");
3672
+ expect(locationUrl.absUrl).toBe(
3295
3673
  "http://server/pre/index.html#/http://example.com/",
3296
3674
  );
3297
3675
  });
3298
3676
 
3299
3677
  it("should allow navigating outside the original base URL", () => {
3300
- locationUrl = new LocationHashbangUrl(
3678
+ locationUrl = new Location(
3301
3679
  "http://server/pre/index.html",
3302
3680
  "http://server/pre/",
3681
+ false,
3303
3682
  "#",
3304
3683
  );
3305
3684
 
3306
- locationUrl.$$parse("http://server/next/index.html");
3307
- expect(locationUrl.url()).toBe("");
3308
- expect(locationUrl.absUrl()).toBe("http://server/next/index.html");
3685
+ locationUrl.parse("http://server/next/index.html");
3686
+ expect(locationUrl.getUrl()).toBe("");
3687
+ expect(locationUrl.absUrl).toBe("http://server/next/index.html");
3309
3688
  });
3310
3689
  });
3311
3690
 
@@ -3315,7 +3694,7 @@ describe("$location", () => {
3315
3694
  // const parser = document.createElement("a");
3316
3695
  // parser.href = options.initialUrl;
3317
3696
 
3318
- // $windowProvider.$get = function () {
3697
+ // $windowProvider.$get = () => {
3319
3698
  // const win = {};
3320
3699
  // angular.extend(win, window);
3321
3700
  // // Ensure `window` is a reference to the mock global object, so that
@@ -3377,7 +3756,7 @@ describe("$location", () => {
3377
3756
  // $sniffer,
3378
3757
  // $$taskTrackerFactory,
3379
3758
  // );
3380
- // browser.baseHref = function () {
3759
+ // browser.baseHref = () => {
3381
3760
  // return options.baseHref;
3382
3761
  // };
3383
3762
  // return browser;
@@ -3399,8 +3778,8 @@ describe("$location", () => {
3399
3778
  }
3400
3779
 
3401
3780
  function parseLinkAndReturn(location, url, relHref) {
3402
- if (location.$$parseLinkUrl(url, relHref)) {
3403
- return location.absUrl();
3781
+ if (location.parseLinkUrl(url, relHref)) {
3782
+ return location.absUrl;
3404
3783
  }
3405
3784
  return undefined;
3406
3785
  }