Make trailing slashes consistent

This commit is contained in:
thepaperpilot 2024-02-18 16:35:41 +00:00
parent 886c3bbb3a
commit dae532627c

View file

@ -124,8 +124,9 @@ export function initGalaxy({
onLoggedInChanged
}) {
return new Promise((accept, reject) => {
acceptedOrigins = acceptedOrigins ?? ["https://galaxy.click/"];
if (acceptedOrigins.includes(document.referrer)) {
acceptedOrigins = acceptedOrigins.map(url =>
url.replace(/\/?$/, '/')) ?? ["https://galaxy.click/"];
if (acceptedOrigins.includes(document.referrer.replace(/\/?$/, '/'))) {
// Callbacks to resolve promises
/** @type function(SaveListResponse["list"]):void */
let saveListAccept,
@ -180,7 +181,7 @@ export function initGalaxy({
};
window.addEventListener("message", e => {
if (e.origin === galaxy.origin) {
if (e.origin.replace(/\/?$/, '/') === galaxy.origin.replace(/\/?$/, '/')) {
console.log("Received message from Galaxy", e.data);
/** @type GalaxyResponse */
const data = e.data;