UNPKG

env-var

Version:

Verification, sanitization, and type coercion for environment variables in Node.js

14 lines (10 loc) 230 B
'use strict' const asString = require('./string') module.exports = function asUrlObject (value) { const ret = asString(value) try { return new URL(ret) } catch (e) { throw new Error('should be a valid URL') } }