Minor UX and code improvements
This commit is contained in:
@@ -25,9 +25,9 @@ export function isRunningLocally(request: Request): boolean {
|
|||||||
|
|
||||||
// Private IP ranges check
|
// Private IP ranges check
|
||||||
const ipParts = hostname.split('.').map(Number);
|
const ipParts = hostname.split('.').map(Number);
|
||||||
|
|
||||||
// Check if valid IP address
|
// Check if the IP address is valid
|
||||||
if (ipParts.length !== 4 || ipParts.some(part => isNaN(part) || part < 0 || part > 255)) {
|
if (ipParts.length !== 4 || ipParts.some((part) => isNaN(part) || part < 0 || part > 255)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,8 @@ export function isRunningLocally(request: Request): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} catch {
|
} catch (error) {
|
||||||
|
console.info('Failed to check if the request is running locally', error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import {
|
|||||||
escapeHtml,
|
escapeHtml,
|
||||||
generateHash,
|
generateHash,
|
||||||
generateRandomCode,
|
generateRandomCode,
|
||||||
|
isRunningLocally,
|
||||||
splitArrayInChunks,
|
splitArrayInChunks,
|
||||||
validateEmail,
|
validateEmail,
|
||||||
validateUrl,
|
validateUrl,
|
||||||
isRunningLocally,
|
|
||||||
} from './misc.ts';
|
} from './misc.ts';
|
||||||
|
|
||||||
Deno.test('that escapeHtml works', () => {
|
Deno.test('that escapeHtml works', () => {
|
||||||
@@ -248,7 +248,6 @@ Deno.test('that convertObjectToFormData works', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Deno.test('that isRunningLocally works', () => {
|
Deno.test('that isRunningLocally works', () => {
|
||||||
const tests: { url: string; expected: boolean }[] = [
|
const tests: { url: string; expected: boolean }[] = [
|
||||||
{ url: 'http://localhost:8000', expected: true },
|
{ 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://192.168.0.1:8000', expected: true },
|
||||||
{ url: 'http://example.com', expected: false },
|
{ url: 'http://example.com', expected: false },
|
||||||
{ url: 'http://68.18.161.245:8000', 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) {
|
for (const test of tests) {
|
||||||
@@ -267,4 +269,3 @@ Deno.test('that isRunningLocally works', () => {
|
|||||||
assertEquals(result, test.expected);
|
assertEquals(result, test.expected);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ export default function Login({ data }: PageProps<Data, FreshContextState>) {
|
|||||||
{data?.notice
|
{data?.notice
|
||||||
? (
|
? (
|
||||||
<section class='notification-success'>
|
<section class='notification-success'>
|
||||||
<h3>Verify your email!</h3>
|
<h3>{isEmailEnabled() ? 'Verify your email!' : 'Account created!'}</h3>
|
||||||
<p>{data?.notice}</p>
|
<p>{data?.notice}</p>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user