mirror of
https://github.com/SomboChea/ui
synced 2024-11-16 19:24:28 +07:00
28 lines
837 B
TypeScript
28 lines
837 B
TypeScript
|
import isURLValidator from 'validator/lib/isURL';
|
||
|
import isEmailValidator from 'validator/lib/isEmail';
|
||
|
import '../../types';
|
||
|
|
||
|
export function isURL(url): boolean {
|
||
|
return isURLValidator(url || '', {
|
||
|
protocols: ['http', 'https', 'git+https'],
|
||
|
require_protocol: true,
|
||
|
});
|
||
|
}
|
||
|
|
||
|
export function isEmail(email): boolean {
|
||
|
return isEmailValidator(email || '');
|
||
|
}
|
||
|
|
||
|
export function getRegistryURL(): string {
|
||
|
// Don't add slash if it's not a sub directory
|
||
|
return `${location.origin}${location.pathname === '/' ? '' : location.pathname}`;
|
||
|
}
|
||
|
|
||
|
export function getBaseNamePath(): string {
|
||
|
return window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix;
|
||
|
}
|
||
|
|
||
|
export function getRootPath(): string {
|
||
|
return window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.base;
|
||
|
}
|