diff --git a/lib/utils/misc.ts b/lib/utils/misc.ts index 955f87e..8f30f50 100644 --- a/lib/utils/misc.ts +++ b/lib/utils/misc.ts @@ -25,9 +25,9 @@ export function isRunningLocally(request: Request): boolean { // Private IP ranges check const ipParts = hostname.split('.').map(Number); - - // Check if valid IP address - if (ipParts.length !== 4 || ipParts.some(part => isNaN(part) || part < 0 || part > 255)) { + + // Check if the IP address is valid + if (ipParts.length !== 4 || ipParts.some((part) => isNaN(part) || part < 0 || part > 255)) { return false; } @@ -47,7 +47,8 @@ export function isRunningLocally(request: Request): boolean { } return false; - } catch { + } catch (error) { + console.info('Failed to check if the request is running locally', error); return false; } } diff --git a/lib/utils/misc_test.ts b/lib/utils/misc_test.ts index 339e9e6..029ab4c 100644 --- a/lib/utils/misc_test.ts +++ b/lib/utils/misc_test.ts @@ -5,10 +5,10 @@ import { escapeHtml, generateHash, generateRandomCode, + isRunningLocally, splitArrayInChunks, validateEmail, validateUrl, - isRunningLocally, } from './misc.ts'; Deno.test('that escapeHtml works', () => { @@ -248,7 +248,6 @@ Deno.test('that convertObjectToFormData works', () => { } }); - Deno.test('that isRunningLocally works', () => { const tests: { url: string; expected: boolean }[] = [ { url: 'http://localhost:8000', expected: true }, @@ -259,6 +258,9 @@ Deno.test('that isRunningLocally works', () => { { url: 'http://192.168.0.1:8000', expected: true }, { url: 'http://example.com', expected: false }, { url: 'http://68.18.161.245:8000', expected: false }, + { url: 'https://example.com', expected: false }, + { url: 'http://2000.10.5000.1111', expected: false }, + { url: 'http://192.168.0.1', expected: true }, ]; for (const test of tests) { @@ -267,4 +269,3 @@ Deno.test('that isRunningLocally works', () => { assertEquals(result, test.expected); } }); - diff --git a/routes/login.tsx b/routes/login.tsx index 8ea9047..7bd6b67 100644 --- a/routes/login.tsx +++ b/routes/login.tsx @@ -150,7 +150,7 @@ export default function Login({ data }: PageProps) { {data?.notice ? (
-

Verify your email!

+

{isEmailEnabled() ? 'Verify your email!' : 'Account created!'}

{data?.notice}

)