Skip to content

Commit e2faf5d

Browse files
docs(LocationServices): Clarify docs for url()
1 parent ac00f9a commit e2faf5d

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/common/coreservices.ts

+27-2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,29 @@ export interface LocationServices extends Disposable {
5050
/**
5151
* Gets the current url string
5252
*
53+
* The URL is normalized using the internal [[path]]/[[search]]/[[hash]] values.
54+
*
55+
* For example, the URL may be stored in the hash ([[HashLocationServices]]) or
56+
* have a base HREF prepended ([[PushStateLocationServices]]).
57+
*
58+
* The raw URL in the browser might be:
59+
*
60+
* ```
61+
* http://mysite.com/somepath/index.html#/internal/path/123?param1=foo#anchor
62+
* ```
63+
*
64+
* or
65+
*
66+
* ```
67+
* http://mysite.com/basepath/internal/path/123?param1=foo#anchor
68+
* ```
69+
*
70+
* then this method returns:
71+
*
72+
* ```
73+
* /internal/path/123?param1=foo#anchor
74+
* ```
75+
*
5376
*
5477
* #### Example:
5578
* ```js
@@ -70,7 +93,9 @@ export interface LocationServices extends Disposable {
7093
* locationServices.url("/some/path?query=value#anchor", true);
7194
* ```
7295
*
73-
* @param newurl The new value for the URL
96+
* @param newurl The new value for the URL.
97+
* This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.
98+
* It should not include the protocol, site, port, or base path of an absolute HREF.
7499
* @param replace When true, replaces the current history entry (instead of appending it) with this new url
75100
* @param state The history's state object, i.e., pushState (if the LocationServices implementation supports it)
76101
* @return the url (after potentially being processed)
@@ -144,7 +169,7 @@ export interface LocationConfig extends Disposable {
144169
*/
145170
host(): string;
146171
/**
147-
* Gets the base Href, e.g., `http://localhost/approot`
172+
* Gets the base Href, e.g., `http://localhost/approot/`
148173
*
149174
* @return the application's base href
150175
*/

src/vanilla/baseLocationService.ts

+24
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,31 @@ export abstract class BaseLocationServices implements LocationServices, Disposab
2323
_location: LocationLike;
2424
_history: HistoryLike;
2525

26+
/**
27+
* This should return the current internal URL representation.
28+
*
29+
* The internal URL includes only the portion that UI-Router matches.
30+
* It does not include:
31+
* - protocol
32+
* - server
33+
* - port
34+
* - base href or hash
35+
*/
2636
abstract _get(): string;
37+
38+
/**
39+
* This should set the current URL.
40+
*
41+
* The `url` param should include only the portion that UI-Router matches on.
42+
* It should not include:
43+
* - protocol
44+
* - server
45+
* - port
46+
* - base href or hash
47+
*
48+
* However, after this function completes, the browser URL should reflect the entire (fully qualified)
49+
* HREF including those data.
50+
*/
2751
abstract _set(state: any, title: string, url: string, replace: boolean);
2852

2953
hash = () => parseUrl(this._get()).hash;

0 commit comments

Comments
 (0)