refactor: install eslint-plugin-regexp (#6906)

* refactor: install eslint-plugin-regexp

* simplify

* simplify

* fix
This commit is contained in:
Joshua Chen 2022-03-13 18:32:17 +08:00 committed by GitHub
parent 127183e70e
commit 3a4b9b4c30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 145 additions and 83 deletions

View file

@ -58,7 +58,7 @@ export function normalizeUrl(rawUrls: string[]): string {
if (i > 0) {
// Removing the starting slashes for each component but the first.
component = component.replace(
/^[/]+/,
/^\/+/,
// Special case where the first element of rawUrls is empty
// ["", "/hello"] => /hello
component[0] === '/' && !hasStartingSlash ? '/' : '',
@ -68,7 +68,7 @@ export function normalizeUrl(rawUrls: string[]): string {
hasEndingSlash = component[component.length - 1] === '/';
// Removing the ending slashes for each component but the last. For the
// last component we will combine multiple slashes to a single one.
component = component.replace(/[/]+$/, i < urls.length - 1 ? '' : '/');
component = component.replace(/\/+$/, i < urls.length - 1 ? '' : '/');
}
hasStartingSlash = true;