1
0
Fork 1
mirror of https://github.com/SomboChea/ui synced 2024-05-20 10:21:36 +07:00
verdaccio-ui/src/webui/utils/url.js
2019-05-17 07:58:56 +02:00

27 lines
689 B
JavaScript

import isURLValidator from 'validator/lib/isURL';
import isEmailValidator from 'validator/lib/isEmail';
export function isURL(url) {
return isURLValidator(url || '', {
protocols: ['http', 'https', 'git+https'],
require_protocol: true,
});
}
export function isEmail(email) {
return isEmailValidator(email || '');
}
export function getRegistryURL() {
// Don't add slash if it's not a sub directory
return `${location.origin}${location.pathname === '/' ? '' : location.pathname}`;
}
export function getBaseNamePath() {
return window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix;
}
export function getRootPath() {
return window.__VERDACCIO_BASENAME_UI_OPTIONS.base;
}