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) {