UI: Fixed validation issues for URLs on the mobile page configuration, including Unicode symbols

This commit is contained in:
Vladyslav_Prykhodko 2025-01-27 19:01:43 +02:00
parent 862f8e0d74
commit f2b5aa9549
2 changed files with 10 additions and 3 deletions

View File

@ -24,7 +24,12 @@ import {
Validator, Validator,
Validators Validators
} from '@angular/forms'; } from '@angular/forms';
import { CustomMobilePage, MobilePageType, mobilePageTypeTranslations } from '@shared/models/mobile-app.models'; import {
CustomMobilePage,
MobilePageType,
mobilePageTypeTranslations,
WEB_URL_REGEX
} from '@shared/models/mobile-app.models';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { getCurrentAuthUser } from '@core/auth/auth.selectors'; import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { Authority } from '@shared/models/authority.enum'; import { Authority } from '@shared/models/authority.enum';
@ -63,8 +68,8 @@ export class CustomMobilePageComponent implements ControlValueAccessor, Validato
label: ['', [Validators.required, Validators.pattern(/\S/)]], label: ['', [Validators.required, Validators.pattern(/\S/)]],
type: [MobilePageType.DASHBOARD], type: [MobilePageType.DASHBOARD],
dashboardId: this.fb.control<string>(null, Validators.required), dashboardId: this.fb.control<string>(null, Validators.required),
url: [{value:'', disabled: true}, [Validators.required, Validators.pattern(/^(https?:\/\/)?(localhost|([\w\-]+\.)+[\w\-]+)(:\d+)?(\/[\w\-._~:\/?#[\]@!$&'()*+,;=%]*)?$/)]], url: [{value:'', disabled: true}, [Validators.required, Validators.pattern(WEB_URL_REGEX)]],
path: [{value:'', disabled: true}, [Validators.required, Validators.pattern(/^(\/[\w\-._~:\/?#[\]@!$&'()*+,;=%]*)?$/)]] path: [{value:'', disabled: true}, [Validators.required, Validators.pattern(/^(\/[\w\-._~:/?#[\]@!$&'()*+,;=%]*)?$/)]]
}); });
private propagateChange = (_val: any) => {}; private propagateChange = (_val: any) => {};

View File

@ -21,6 +21,8 @@ import { OAuth2ClientInfo, PlatformType } from '@shared/models/oauth2.models';
import { MobileAppBundleId } from '@shared/models/id/mobile-app-bundle-id'; import { MobileAppBundleId } from '@shared/models/id/mobile-app-bundle-id';
import { deepClone, isNotEmptyStr } from '@core/utils'; import { deepClone, isNotEmptyStr } from '@core/utils';
export const WEB_URL_REGEX = /^(https?:\/\/)?(localhost|([\p{L}\p{M}\w-]+\.)+[\p{L}\p{M}\w-]+)(:\d+)?(\/[\w\-._~:/?#[\]@!$&'()*+,;=%\p{L}\p{N}]*)?$/u;
export interface QrCodeSettings extends HasTenantId { export interface QrCodeSettings extends HasTenantId {
useDefaultApp: boolean; useDefaultApp: boolean;
mobileAppBundleId: MobileAppBundleId mobileAppBundleId: MobileAppBundleId