resolve-runtime
Version:
This package create server with resolve.
49 lines (36 loc) • 1.39 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.nonEmptyString = exports.string = exports.isString = void 0;
var _url = _interopRequireDefault(require("url"));
var _get_root_based_url = _interopRequireDefault(require("./get_root_based_url"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const isString = value => value != null && value.constructor === String;
exports.isString = isString;
const string = (value, name) => {
if (!isString(value)) {
resolveLog('warn', 'Value is not a string', value);
throw new Error(`${name} must be a string`);
}
};
exports.string = string;
const nonEmptyString = (value, name) => {
string(value, name);
if (value === '') {
resolveLog('warn', 'Value is not empty string', value);
throw new Error(`${name} must be a non-empty string`);
}
};
exports.nonEmptyString = nonEmptyString;
const validate = {
nonEmptyString
};
const getStaticBasedPath = (rootPath, staticPath, filename) => {
validate.nonEmptyString(staticPath, 'Static path');
validate.nonEmptyString(filename, 'Filename');
return (0, _get_root_based_url.default)(rootPath, _url.default.resolve(`${staticPath}/`, `./${filename}`));
};
var _default = getStaticBasedPath;
exports.default = _default;
//# sourceMappingURL=get_static_based_path.js.map
;