5180 fichiers 38.5 Mo 0 téléchargements 241 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / api / octane / resolveHabboPageUrl.ts
resolveHabboPageUrl.ts 974 o Télécharger le fichier
/**
 * The URL of a help page (habbopages) for a path taken from a link event, or null when the path
 * would leave the configured folder ("..", encoded slashes, another host or scheme).
 */
export const resolveHabboPageUrl = (base: string, path: string, location: string = globalThis.location?.href): string | null => {
    if (!base || !path) return null;

    let decoded: string;

    try {
        decoded = decodeURIComponent(path);
    } catch {
        return null;
    }

    if (decoded.includes('\\') || decoded.startsWith('/') || /^[a-z][a-z0-9+.-]*:/i.test(decoded)) return null;
    if (decoded.split('/').some((segment) => segment === '..' || segment === '.')) return null;

    try {
        const baseUrl = new URL(base, location);
        const url = new URL(base + path, location);

        if (url.origin !== baseUrl.origin || !url.pathname.startsWith(baseUrl.pathname)) return null;

        return url.href;
    } catch {
        return null;
    }
};
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser