mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
refactor: install eslint-plugin-regexp (#6906)
* refactor: install eslint-plugin-regexp * simplify * simplify * fix
This commit is contained in:
parent
127183e70e
commit
3a4b9b4c30
23 changed files with 145 additions and 83 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue