diff options
author | Liang Yi <[email protected]> | 2022-03-16 14:26:15 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2022-03-16 14:26:15 +0800 |
commit | 50a252fdd7e5652d344e9f1eb82ff755d55fe8a5 (patch) | |
tree | 204a1fd629f29e1be7e987820b3f829f4c54377d /frontend/src/utilities/index.ts | |
parent | f81972b291b73f5771c40359f18d6470b23e2650 (diff) | |
download | bazarr-50a252fdd7e5652d344e9f1eb82ff755d55fe8a5.tar.gz bazarr-50a252fdd7e5652d344e9f1eb82ff755d55fe8a5.zip |
Frontend improvement and cleanup (#1690)
* Replace Create-React-App with Vite.js
* Update React-Router to v6
* Cleanup unused codes
Diffstat (limited to 'frontend/src/utilities/index.ts')
-rw-r--r-- | frontend/src/utilities/index.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/frontend/src/utilities/index.ts b/frontend/src/utilities/index.ts index b84c5cf3d..cba997eca 100644 --- a/frontend/src/utilities/index.ts +++ b/frontend/src/utilities/index.ts @@ -3,7 +3,7 @@ import { Dispatch } from "react"; import { isEpisode, isMovie, isSeries } from "./validate"; export function copyToClipboard(s: string) { - let field = document.createElement("textarea"); + const field = document.createElement("textarea"); field.innerText = s; document.body.appendChild(field); field.select(); @@ -15,7 +15,7 @@ export function copyToClipboard(s: string) { export function toggleState( dispatch: Dispatch<boolean>, wait: number, - start: boolean = false + start = false ) { dispatch(!start); setTimeout(() => dispatch(start), wait); @@ -37,7 +37,7 @@ export function GetItemId<T extends object>(item: T): number | undefined { } } -export function BuildKey(...args: any[]) { +export function BuildKey(...args: unknown[]) { return args.join("-"); } @@ -49,6 +49,12 @@ export function ScrollToTop() { window.scrollTo(0, 0); } +const pathReplaceReg = new RegExp("/{1,}", "g"); +export function pathJoin(...parts: string[]) { + const separator = "/"; + return parts.join(separator).replace(pathReplaceReg, separator); +} + export function filterSubtitleBy( subtitles: Subtitle[], languages: Language.Info[] |