diff --git a/.eslintrc.js b/.eslintrc.js index b78b730950..7242938a8e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -194,7 +194,6 @@ module.exports = { 'DashboardPage': 'writable', 'Emby': 'readonly', 'getParameterByName': 'writable', - 'getWindowLocationSearch': 'writable', 'Globalize': 'writable', 'Hls': 'writable', 'dfnshelper': 'writable', diff --git a/src/components/appRouter.js b/src/components/appRouter.js index 4e45f343c8..4a7224fe5e 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -12,6 +12,7 @@ import Dashboard from '../scripts/clientUtils'; import ServerConnections from './ServerConnections'; import alert from './alert'; import reactControllerFactory from './reactControllerFactory'; +import { getWindowLocationSearch } from '../utils/url.ts'; class AppRouter { allRoutes = []; @@ -678,19 +679,6 @@ class AppRouter { }; } - getWindowLocationSearch() { - const currentPath = this.currentRouteInfo ? (this.currentRouteInfo.path || '') : ''; - - const index = currentPath.indexOf('?'); - let search = ''; - - if (index !== -1) { - search = currentPath.substring(index); - } - - return search || ''; - } - showGuide() { Dashboard.navigate('livetv.html?tab=1'); } diff --git a/src/scripts/clientUtils.js b/src/scripts/clientUtils.js index ac50e57c5a..bc9e899490 100644 --- a/src/scripts/clientUtils.js +++ b/src/scripts/clientUtils.js @@ -10,6 +10,7 @@ import datetime from '../scripts/datetime'; import DirectoryBrowser from '../components/directorybrowser/directorybrowser'; import dialogHelper from '../components/dialogHelper/dialogHelper'; import itemIdentifier from '../components/itemidentifier/itemidentifier'; +import { getWindowLocationSearch } from '../utils/url.ts'; export function getCurrentUser() { return window.ApiClient.getCurrentUser(false); diff --git a/src/scripts/site.js b/src/scripts/site.js index 263fed80d2..593e3475c6 100644 --- a/src/scripts/site.js +++ b/src/scripts/site.js @@ -26,6 +26,7 @@ import './routes'; import '../components/themeMediaPlayer'; import './autoBackdrops'; import { pageClassOn, serverAddress } from './clientUtils'; +import { getWindowLocationSearch } from '../utils/url.ts'; import './screensavermanager'; import './serverNotifications'; import '../components/playback/playerSelectionMenu'; @@ -41,21 +42,6 @@ import SyncPlayHtmlAudioPlayer from '../components/syncPlay/ui/players/HtmlAudio import { currentSettings } from './settings/userSettings'; import taskButton from './taskbutton'; -// TODO: Move this elsewhere -window.getWindowLocationSearch = function(win) { - let search = (win || window).location.search; - - if (!search) { - const index = window.location.href.indexOf('?'); - - if (index != -1) { - search = window.location.href.substring(index); - } - } - - return search || ''; -}; - // TODO: Move this elsewhere window.getParameterByName = function(name, url) { name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]'); diff --git a/src/utils/url.ts b/src/utils/url.ts new file mode 100644 index 0000000000..fa4489c626 --- /dev/null +++ b/src/utils/url.ts @@ -0,0 +1,13 @@ +export const getWindowLocationSearch = (win: Window | null | undefined) => { + let search = (win || window).location.search; + + if (!search) { + const index = window.location.href.indexOf('?'); + + if (index != -1) { + search = window.location.href.substring(index); + } + } + + return search || ''; +};