-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat($location): allow automatic rewriting of links to be disabled #9487
Conversation
@tbosch lgty? |
}); | ||
|
||
|
||
it('should default to enabled:false and requireBase:true', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this test because it's the same test as the one above.
I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS. Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match. If you signed the CLA as a corporation, please let us know the company's name. Thanks a bunch! PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR. |
@@ -657,6 +658,8 @@ function $LocationProvider(){ | |||
* `enabled` and `requireBase` are true, and a base tag is not present, an error will be | |||
* thrown when `$location` is injected. See the | |||
* {@link guide/$location $location guide for more information} | |||
* - **rewriteLinks** - `{boolean}` - Turns off url rewriting for relative links (default: | |||
* `false`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this rather be something like:
* - **rewriteLinks** - `{boolean}` - Sets `html5Mode.rewriteLinks` (default: `true`). When
* html5Mode is enabled, it enables/disables url rewriting for relative links.
Also, on line 652 above:
* If object, sets `enabled`, `requireBase` and `rewriteLinks` to respective values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think that "html5Mode.rewriteLinks" is meaning less to the user. it's an implementation detail that is not visible to the user unless they read the source code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrite these paragraphs
LGTM, agree with the comments by @gkalpak. |
abdaab7
to
30996f8
Compare
Currently, when the location provider is set to html5 mode, all links on the page are hijacked and automatically rewritten. While this may be desirable behavior in some cases (such as using ngRoute), not all cases where html5 mode are enabled imply the desire for this behavior. One example would be an application using the [ui-router](https://github.com/angular-ui/ui-router) library, with some pages that exist outside of angular. Links that are meant to go through the router use the `ui-sref` directive, so the rewrite behavior is unnecessary. Closes angular#5487
6795241
to
b3e09be
Compare
* true, and a base tag is not present, an error will be thrown when `$location` is injected. | ||
* See the {@link guide/$location $location guide for more information} | ||
* - **rewriteLinks** - `{boolean}` - (default: `false`) When html5Mode is enabled, disables | ||
* url rewriting for relative linksTurns off url rewriting for relative links. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description of rewriteLinks
needs...rewriting.
For one, it is true
by default.
Besides the obvious left over sentence at the end, I think that saying it disables url rewriting is not accurate, since it depends on the value. How about:
When html5Mode is enabled, it enables/disables url rewriting for relative links.
Currently, when the location provider is set to html5 mode, all links
on the page are hijacked and automatically rewritten. While this may be
desirable behavior in some cases (such as using ngRoute), not all cases
where html5 mode are enabled imply the desire for this behavior.
One example would be an application using the
ui-router library, with some
pages that exist outside of angular. Links that are meant to go through
the router use the
ui-sref
directive, so the rewrite behavior isunnecessary.
Closes #5487