Skip to content

Commit 35c4c61

Browse files
authored
Merge pull request #1815 from appwrite/expand-hostname
Allow ip-addresses and chrome extension ids
2 parents 0cfe10c + 580779f commit 35c4c61

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

src/lib/helpers/string.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,10 @@ export function formatNum(number: number): string {
5353
* Returns a regex to check hostname validity. Supports wildcards too!
5454
*/
5555
export const hostnameRegex = String.raw`(\*)|(\*\.)?(?!-)[A-Za-z0-9\-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,18}|localhost`;
56+
57+
/**
58+
* Returns a regex to check hostname validity.
59+
*
60+
* Supports domains, localhost, wildcards, ip-addresses and Chrome extension IDs!
61+
*/
62+
export const extendedHostnameRegex = String.raw`(\*)|(\*\.)?((?!-)[A-Za-z0-9\-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,18}|localhost|(\d{1,3}\.){3}\d{1,3}|[a-z0-9]{32})`;

src/routes/(console)/project-[region]-[project]/overview/platforms/[platform]/web.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { onMount } from 'svelte';
99
import { project } from '../../../store';
1010
import { platform } from './store';
11-
import { hostnameRegex } from '$lib/helpers/string';
11+
import { extendedHostnameRegex } from '$lib/helpers/string';
1212
1313
let hostname: string = null;
1414
@@ -50,7 +50,7 @@
5050
id="hostname"
5151
label="Hostname"
5252
bind:value={hostname}
53-
pattern={hostnameRegex}
53+
pattern={extendedHostnameRegex}
5454
patternError="Please enter a valid hostname"
5555
placeholder="myapp.com" />
5656
</FormList>

src/routes/(console)/project-[region]-[project]/overview/platforms/wizard/flutter/step1.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { Submit, trackEvent } from '$lib/actions/analytics';
99
import { PlatformType } from '@appwrite.io/console';
1010
import { isValueOfStringEnum } from '$lib/helpers/types';
11-
import { hostnameRegex } from '$lib/helpers/string';
11+
import { extendedHostnameRegex } from '$lib/helpers/string';
1212
1313
// enum Platform {
1414
// Android = 'flutter-android',
@@ -174,7 +174,7 @@
174174
placeholder={placeholder[platform].hostname}
175175
tooltip={placeholder[platform].tooltip}
176176
required
177-
pattern={hostnameRegex}
177+
pattern={extendedHostnameRegex}
178178
patternError="Please enter a valid hostname"
179179
bind:value={$createPlatform.hostname} />
180180

src/routes/(console)/project-[region]-[project]/overview/platforms/wizard/web/step1.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import { createPlatform } from '../store';
99
import { Submit, trackEvent } from '$lib/actions/analytics';
1010
import { PlatformType } from '@appwrite.io/console';
11-
import { hostnameRegex } from '$lib/helpers/string';
11+
import { extendedHostnameRegex } from '$lib/helpers/string';
1212
1313
const projectId = $page.params.project;
1414
const suggestions = ['*.vercel.app', '*.netlify.app', '*.gitpod.io'];
@@ -60,7 +60,7 @@
6060
placeholder="localhost"
6161
tooltip="The hostname that your website will use to interact with the Appwrite APIs in production or development environments. No protocol or port number required."
6262
required
63-
pattern={hostnameRegex}
63+
pattern={extendedHostnameRegex}
6464
patternError="Please enter a valid hostname"
6565
bind:value={$createPlatform.hostname} />
6666

0 commit comments

Comments
 (0)