mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #1652 from appwrite/fix-invalid-hostname
Fix invalid hostnames on platform creation
This commit is contained in:
5 files changed
+24
-2
No files matched your search
@@ -11,6 +11,8 @@
|
||||
export let id: string;
|
||||
export let name: string = id;
|
||||
export let value = '';
|
||||
export let pattern: string = null;
|
||||
export let patternError: string = '';
|
||||
export let placeholder = '';
|
||||
export let required = false;
|
||||
export let hideRequired = false;
|
||||
@@ -45,6 +47,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (patternError && element.validity.patternMismatch) {
|
||||
error = patternError;
|
||||
return;
|
||||
}
|
||||
|
||||
error = element.validationMessage;
|
||||
};
|
||||
|
||||
@@ -118,6 +125,7 @@
|
||||
{disabled}
|
||||
{readonly}
|
||||
{required}
|
||||
{pattern}
|
||||
{maxlength}
|
||||
autocomplete={autocomplete ? 'on' : 'off'}
|
||||
type="text"
|
||||
|
||||
@@ -48,3 +48,8 @@ const formatter = Intl.NumberFormat('en', {
|
||||
export function formatNum(number: number): string {
|
||||
return formatter.format(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a regex to check hostname validity. Supports wildcards too!
|
||||
*/
|
||||
export const hostnameRegex = String.raw`(\*)|(\*\.)?(?!-)[A-Za-z0-9\-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,18}`;
|
||||
@@ -8,6 +8,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
import { hostnameRegex } from '$lib/helpers/string';
|
||||
|
||||
let hostname: string = null;
|
||||
|
||||
@@ -28,7 +29,7 @@
|
||||
await invalidate(Dependencies.PLATFORM);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Hostname has been updated'
|
||||
message: 'Platform hostname has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
@@ -49,7 +50,8 @@
|
||||
id="hostname"
|
||||
label="Hostname"
|
||||
bind:value={hostname}
|
||||
required
|
||||
pattern={hostnameRegex}
|
||||
patternError="Please enter a valid hostname"
|
||||
placeholder="myapp.com" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
import { PlatformType } from '@appwrite.io/console';
|
||||
import { isValueOfStringEnum } from '$lib/helpers/types';
|
||||
import { hostnameRegex } from '$lib/helpers/string';
|
||||
|
||||
// enum Platform {
|
||||
// Android = 'flutter-android',
|
||||
@@ -173,6 +174,8 @@
|
||||
placeholder={placeholder[platform].hostname}
|
||||
tooltip={placeholder[platform].tooltip}
|
||||
required
|
||||
pattern={hostnameRegex}
|
||||
patternError="Please enter a valid hostname"
|
||||
bind:value={$createPlatform.hostname} />
|
||||
|
||||
<div class="u-flex u-gap-16 u-margin-block-start-8">
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { createPlatform } from '../store';
|
||||
import { Submit, trackEvent } from '$lib/actions/analytics';
|
||||
import { PlatformType } from '@appwrite.io/console';
|
||||
import { hostnameRegex } from '$lib/helpers/string';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
const suggestions = ['*.vercel.app', '*.netlify.app', '*.gitpod.io'];
|
||||
@@ -59,7 +60,10 @@
|
||||
placeholder="localhost"
|
||||
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."
|
||||
required
|
||||
pattern={hostnameRegex}
|
||||
patternError="Please enter a valid hostname"
|
||||
bind:value={$createPlatform.hostname} />
|
||||
|
||||
<div class="u-flex u-gap-16 u-margin-block-start-8">
|
||||
{#each suggestions as suggestion}
|
||||
<Pill
|
||||
|
||||
Reference in new issue
Block a user