UNPKG

@platform/cell.schema

Version:

URI and database schemas for the `cell.os`.

19 lines (18 loc) 668 B
import { R, value } from '../common'; export function toPort(input) { const text = R.pipe(stripHttp, stripSlash)(input || '').split(':')[1]; return text === undefined ? undefined : value.toNumber(text); } export function stripHttp(input) { return (input || '').replace(/^http\:\/\//, '').replace(/^https\:\/\//, ''); } export function stripPort(input) { return (input || '').replace(/\:\d*$/, ''); } export function stripSlash(input) { return (input || '').replace(/^\/*/, '').replace(/\/*$/, ''); } export function toProtocol(input) { input = input || ''; return input.startsWith('localhost') && !input.includes('.') ? 'http' : 'https'; }