'use strict';

// Node.js built-ins

const url = require('url');

// this module

function isURL (string) {
  try {
    let result = url.parse(string);
    return !!(result.protocol && result.host);
  } catch (err) {
    return false;
  }
}

function getOrigin (string) {
  try {
    let result = url.parse(string);
    let host = result.host || `${result.hostname}:${result.port}`;
    return `${result.protocol}//${host}`;
  } catch (err) {
    return '';
  }
}

function toHTTPS (string) {
  let result = url.parse(string);
  result.protocol = 'https:';
  return url.format(result);
}

module.exports = {
  getOrigin,
  isURL,
  toHTTPS
};

@@ -261,34 +261,24 @@
  (string) %7B%0A
-  try %7B%0A  
   let result
@@ -299,18 +299,16 @@
 tring);%0A
-  
   let ho
@@ -362,26 +362,24 @@
 t.port%7D%60;%0A  
- 
- 
 return %60$%7Bre
@@ -408,45 +408,8 @@
 %7D%60;%0A
-  %7D catch (err) %7B%0A    return '';%0A  %7D%0A
 %7D%0A%0Af

move "...-utils" modules to "utils" sub-dir