27 lines
630 B
JavaScript
27 lines
630 B
JavaScript
const DEFAULT_SETTINGS = {
|
|
plexUrl: "https://app.plex.tv",
|
|
skipIntro: true,
|
|
skipCredits: true
|
|
};
|
|
|
|
function normalizePlexUrl(input) {
|
|
let value = (input || "").trim();
|
|
if (!value) return DEFAULT_SETTINGS.plexUrl;
|
|
if (!/^https?:\/\//i.test(value)) value = "http://" + value;
|
|
return value;
|
|
}
|
|
|
|
function getHostFromUrl(urlString) {
|
|
try {
|
|
return new URL(urlString).hostname;
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function hostMatchesConfig(currentHostname, configuredUrl) {
|
|
const configuredHost = getHostFromUrl(configuredUrl);
|
|
if (!configuredHost) return false;
|
|
return currentHostname === configuredHost;
|
|
}
|