Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
387 B

  1. 'use strict';
  2. module.exports = (url, opts) => {
  3. if (typeof url !== 'string') {
  4. throw new TypeError(`Expected \`url\` to be of type \`string\`, got \`${typeof url}\``);
  5. }
  6. url = url.trim();
  7. opts = Object.assign({https: false}, opts);
  8. if (/^\.*\/|^(?!localhost)\w+:/.test(url)) {
  9. return url;
  10. }
  11. return url.replace(/^(?!(?:\w+:)?\/\/)/, opts.https ? 'https://' : 'http://');
  12. };