mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 19:13:34 +08:00
`posix.join` will dedupe double forward slashes resulting in incorrect protocol. Closes: #17029
18 lines
486 B
TypeScript
18 lines
486 B
TypeScript
/**
|
|
* @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, '/');
|
|
}
|