1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-02 19:55:18 +02:00

feat: Enhance session cookie domain handling for IP addresses and single-label hostnames

This commit is contained in:
Sean Morley 2025-02-20 10:21:48 -05:00
parent 7cea432353
commit 1c15e85986
4 changed files with 18 additions and 16 deletions

View file

@ -58,8 +58,10 @@ export const actions: Actions = {
// Check if hostname is an IP address
const isIPAddress = /^\d{1,3}(\.\d{1,3}){3}$/.test(hostname);
const isLocalhost = hostname === 'localhost';
const isSingleLabel = hostname.split('.').length === 1;
if (!isIPAddress) {
if (!isIPAddress && !isSingleLabel && !isLocalhost) {
const parsed = psl.parse(hostname);
if (parsed && parsed.domain) {

View file

@ -120,8 +120,10 @@ function handleSuccessfulLogin(event: RequestEvent<RouteParams, '/login'>, respo
// Check if hostname is an IP address
const isIPAddress = /^\d{1,3}(\.\d{1,3}){3}$/.test(hostname);
const isLocalhost = hostname === 'localhost';
const isSingleLabel = hostname.split('.').length === 1;
if (!isIPAddress) {
if (!isIPAddress && !isSingleLabel && !isLocalhost) {
const parsed = psl.parse(hostname);
if (parsed && parsed.domain) {