index.js 268 B

123456789101112131415
  1. 'use strict';
  2. var url = require('url');
  3. var prependHttp = require('prepend-http');
  4. module.exports = function (x) {
  5. var withProtocol = prependHttp(x);
  6. var parsed = url.parse(withProtocol);
  7. if (withProtocol !== x) {
  8. parsed.protocol = null;
  9. }
  10. return parsed;
  11. };