1
0
Fork 1
mirror of https://github.com/SomboChea/ui synced 2024-06-02 01:25:05 +07:00
verdaccio-ui/src/webui/utils/url.js
Juan Picado @jotadeveloper 980dac5b2f
fix: verify validation url and email (#60)
* fix: verify validation url and email

* chore: disable one expect

* fix: lint issue

* fix: fix lint
2019-05-16 07:25:40 -07:00

26 lines
622 B
JavaScript

import validator from 'validator';
export function isURL(url) {
return validator.isURL(url || '', {
protocols: ['http', 'https', 'git+https'],
require_protocol: true,
});
}
export function isEmail(email) {
return validator.isEmail(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;
}