index.js 376 B

123456789101112
  1. 'use strict';
  2. const url = require('url');
  3. const prependHttp = require('prepend-http');
  4. module.exports = (input, options) => {
  5. if (typeof input !== 'string') {
  6. throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof input}\` instead.`);
  7. }
  8. const finalUrl = prependHttp(input, Object.assign({https: true}, options));
  9. return url.parse(finalUrl);
  10. };