Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit e47f077

Browse files
committed
fix($browser): normalize inputted URLs
Fixes #16100 Fixes #16592
1 parent 91f243b commit e47f077

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/ng/browser.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ function Browser(window, document, $log, $sniffer) {
131131
// setter
132132
if (url) {
133133
var sameState = lastHistoryState === state;
134+
var hasTrailingSlash = url[url.length - 1] === '/';
135+
136+
// Normalize the inputted URL
137+
url = urlResolve(url).href;
138+
139+
// ... but keep the (lack of) trailing '/' consistent
140+
if (!hasTrailingSlash && url[url.length - 1] === '/') {
141+
url = url.slice(0, url.length - 1);
142+
}
134143

135144
// Don't change anything if previous and current URLs and states match. This also prevents
136145
// IE<10 from getting into redirect loop when in LocationHashbangInHtml5Url mode.

test/ng/browserSpecs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ describe('browser', function() {
10131013
it('should not interfere with legacy browser url replace behavior', function() {
10141014
inject(function($rootScope) {
10151015
var current = fakeWindow.location.href;
1016-
var newUrl = 'notyet';
1016+
var newUrl = 'http://notyet';
10171017
sniffer.history = false;
10181018
expect(historyEntriesLength).toBe(1);
10191019
browser.url(newUrl, true);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy