-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): baseHref with protocol and locali…
…ze option `posix.join` will dedupe double forward slashes resulting in incorrect protocol. Closes: #17029 (cherry picked from commit 4e65705)
- Loading branch information
1 parent
1f43b5c
commit a05ee30
Showing
5 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
|
||
export function urlJoin(...parts: string[]): string { | ||
const [p, ...rest] = parts; | ||
|
||
// Remove trailing slash from first part | ||
// Join all parts with `/` | ||
// Dedupe double slashes from path names | ||
return p.replace(/\/$/, '') + ('/' + rest.join('/')).replace(/\/\/+/g, '/'); | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/angular_devkit/build_angular/src/utils/url_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import { urlJoin } from './url'; | ||
|
||
describe('urlJoin', () => { | ||
it('should work with absolute url with trailing slash', () => { | ||
expect(urlJoin('http://foo.com/', '/one/')).toBe('http://foo.com/one/'); | ||
}); | ||
|
||
it('should work with absolute url without trailing slash', () => { | ||
expect(urlJoin('http://foo.com', '/one')).toBe('http://foo.com/one'); | ||
}); | ||
|
||
it('should work with absolute url without slashes', () => { | ||
expect(urlJoin('http://foo.com', 'one', 'two')).toBe('http://foo.com/one/two'); | ||
}); | ||
|
||
it('should work with relative url without slashes', () => { | ||
expect(urlJoin('one', 'two', 'three')).toBe('one/two/three'); | ||
}); | ||
|
||
it('should keep trailing slash if empty path is provided', () => { | ||
expect(urlJoin('one/', '')).toBe('one/'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters