@platform/cell.schema
Version:
URI and database schemas for the `cell.os`.
26 lines (25 loc) • 878 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../common");
function toPort(input) {
var text = common_1.R.pipe(stripHttp, stripSlash)(input || '').split(':')[1];
return text === undefined ? undefined : common_1.value.toNumber(text);
}
exports.toPort = toPort;
function stripHttp(input) {
return (input || '').replace(/^http\:\/\//, '').replace(/^https\:\/\//, '');
}
exports.stripHttp = stripHttp;
function stripPort(input) {
return (input || '').replace(/\:\d*$/, '');
}
exports.stripPort = stripPort;
function stripSlash(input) {
return (input || '').replace(/^\/*/, '').replace(/\/*$/, '');
}
exports.stripSlash = stripSlash;
function toProtocol(input) {
input = input || '';
return input.startsWith('localhost') && !input.includes('.') ? 'http' : 'https';
}
exports.toProtocol = toProtocol;