UNPKG

kibana-123

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

21 lines (16 loc) 634 B
import { parse } from 'url'; import { trim } from 'lodash'; import Boom from 'boom'; export function shortUrlAssertValid(url) { const { protocol, hostname, pathname } = parse(url); if (protocol) { throw Boom.notAcceptable(`Short url targets cannot have a protocol, found "${protocol}"`); } if (hostname) { throw Boom.notAcceptable(`Short url targets cannot have a hostname, found "${hostname}"`); } const pathnameParts = trim(pathname, '/').split('/'); if (pathnameParts.length !== 2) { throw Boom.notAcceptable(`Short url target path must be in the format "/app/{{appId}}", found "${pathname}"`); } }