How to use the valid-url.is_web_uri function in valid-url

To help you get started, we’ve selected a few valid-url examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fffunction / backstop-crawl / index.js View on Github external
alias: {
            o: 'outfile',
        },
    }
);

if (cli.flags.limitSimilar) {
    if (!Number.isInteger(cli.flags.limitSimilar)) {
        // Set default if true
        cli.flags.limitSimilar = 3;
    }
}

if (cli.flags.referenceUrl) {

    if (!validurl(cli.flags.referenceUrl)) {
        console.error(
            `> Error: "${cli.flags.referenceUrl}" isn't a valid reference URL`
        );
        process.exit(1);
    }
}

if (cli.input.length > 0) {
    if (validurl(cli.input[0])) {
        crawl(cli.input[0], cli.flags);
    } else {
        console.error(`> Error: "${cli.input[0]}" isn't a valid URL`);
        process.exit(1);
    }
} else {
    cli.showHelp();
github pwa-builder / pwabuilder-lib / lib / manifestTools / manifestCreator / scrapers / start_url.js View on Github external
var start_url = function(opts, callback) {

  var $ = cheerio.load(opts.html);
  var url = opts.url;

  var startUrl = $('link[rel=start]').attr('href');

  if (!startUrl) {
    startUrl = $('[name=msapplication-starturl]').attr('content');
  }

  if (!startUrl) {
    if (url && !isUrl(url)) {
      // if the url exists and is not a valid wbe url (e.g. /foo), then
      // its probably the start_url we want to use
      startUrl = url;
    }
    else if (isUrl(url)) {
      // if we have a valid url, then its more likely that we were given the homepage
      // for the app. So the path is the most likely canidate for the start_url
      startUrl = _url.parse(url).path;
    }
    else {
      // I can't think of a better default
      startUrl = '/';
    }
  }

  if (callback) {
github patrickkettner / manifestation / lib / scrapers / start_url.js View on Github external
const start_url = (opts, callback) => {

  const $ = Cheerio.load(opts.html);
  const url = opts.url;

  let startUrl = $('link[rel=start]').attr('href');

  if (!startUrl) {
    startUrl = $('[name=msapplication-starturl]').attr('content');
  }

  if (!startUrl) {
    if (url && !IsURL(url)) {
      // if the url exists and is not a valid wbe url (e.g. /foo), then
      // its probably the start_url we want to use
      startUrl = url;
    }
    else if (IsURL(url)) {
      // if we have a valid url, then its more likely that we were given the homepage
      // for the app. So the path is the most likely canidate for the start_url
      startUrl = Url.parse(url).path;
    }
    else {
      // I can't think of a better default
      startUrl = '/';
    }
  }

  if (callback) {
github pwa-builder / pwabuilder-lib / lib / manifestTools / manifestCreator / scrapers / start_url.js View on Github external
var $ = cheerio.load(opts.html);
  var url = opts.url;

  var startUrl = $('link[rel=start]').attr('href');

  if (!startUrl) {
    startUrl = $('[name=msapplication-starturl]').attr('content');
  }

  if (!startUrl) {
    if (url && !isUrl(url)) {
      // if the url exists and is not a valid wbe url (e.g. /foo), then
      // its probably the start_url we want to use
      startUrl = url;
    }
    else if (isUrl(url)) {
      // if we have a valid url, then its more likely that we were given the homepage
      // for the app. So the path is the most likely canidate for the start_url
      startUrl = _url.parse(url).path;
    }
    else {
      // I can't think of a better default
      startUrl = '/';
    }
  }

  if (callback) {
    callback(null, startUrl);
  }

  return startUrl;
};
github pwa-builder / pwabuilder-lib / lib / manifestTools / manifestCreator / scrapers / scope.js View on Github external
var scope = function(obj, callback) {

  var url = obj.url;
  var _scope;

  if (url && !isUrl(url)) {
    // if the url exists and is not a valid wbe url (e.g. /foo), then
    // its probably the scope we want to use
    _scope = url;
  }
  else if (isUrl(url)) {
    // if we have a valid url, then its more liekly that we were given the homepage
    // for the app. So the path is the most liekly canidate for the scope
    _scope = _url.parse(url).path;
  }
  else {
    // I can't think of a better default
    _scope = '/';
  }

  if (callback) {
    callback(null, _scope);
github patrickkettner / manifestation / lib / scrapers / scope.js View on Github external
const scope = (obj, callback) => {

  const url = obj.url;
  let _scope;

  if (url && !IsURL(url)) {
    // if the url exists and is not a valid wbe url (e.g. /foo), then
    // its probably the scope we want to use
    _scope = url;
  }
  else if (IsURL(url)) {
    // if we have a valid url, then its more liekly that we were given the homepage
    // for the app. So the path is the most liekly canidate for the scope
    _scope = Url.parse(url).path;
  }
  else {
    // I can't think of a better default
    _scope = '/';
  }

  if (callback) {
    callback(null, _scope);
  }

  return _scope;
};
github pwa-builder / pwabuilder-lib / lib / manifestTools / manifestCreator / scrapers / scope.js View on Github external
var scope = function(obj, callback) {

  var url = obj.url;
  var _scope;

  if (url && !isUrl(url)) {
    // if the url exists and is not a valid wbe url (e.g. /foo), then
    // its probably the scope we want to use
    _scope = url;
  }
  else if (isUrl(url)) {
    // if we have a valid url, then its more liekly that we were given the homepage
    // for the app. So the path is the most liekly canidate for the scope
    _scope = _url.parse(url).path;
  }
  else {
    // I can't think of a better default
    _scope = '/';
  }

  if (callback) {
    callback(null, _scope);
  }

  return _scope;
};
github patrickkettner / manifestation / lib / scrapers / start_url.js View on Github external
const $ = Cheerio.load(opts.html);
  const url = opts.url;

  let startUrl = $('link[rel=start]').attr('href');

  if (!startUrl) {
    startUrl = $('[name=msapplication-starturl]').attr('content');
  }

  if (!startUrl) {
    if (url && !IsURL(url)) {
      // if the url exists and is not a valid wbe url (e.g. /foo), then
      // its probably the start_url we want to use
      startUrl = url;
    }
    else if (IsURL(url)) {
      // if we have a valid url, then its more likely that we were given the homepage
      // for the app. So the path is the most likely canidate for the start_url
      startUrl = Url.parse(url).path;
    }
    else {
      // I can't think of a better default
      startUrl = '/';
    }
  }

  if (callback) {
    callback(null, startUrl);
  }

  return startUrl;
};
github patrickkettner / manifestation / lib / scrapers / scope.js View on Github external
const scope = (obj, callback) => {

  const url = obj.url;
  let _scope;

  if (url && !IsURL(url)) {
    // if the url exists and is not a valid wbe url (e.g. /foo), then
    // its probably the scope we want to use
    _scope = url;
  }
  else if (IsURL(url)) {
    // if we have a valid url, then its more liekly that we were given the homepage
    // for the app. So the path is the most liekly canidate for the scope
    _scope = Url.parse(url).path;
  }
  else {
    // I can't think of a better default
    _scope = '/';
  }

  if (callback) {
    callback(null, _scope);
github fffunction / backstop-crawl / index.js View on Github external
cli.flags.limitSimilar = 3;
    }
}

if (cli.flags.referenceUrl) {

    if (!validurl(cli.flags.referenceUrl)) {
        console.error(
            `> Error: "${cli.flags.referenceUrl}" isn't a valid reference URL`
        );
        process.exit(1);
    }
}

if (cli.input.length > 0) {
    if (validurl(cli.input[0])) {
        crawl(cli.input[0], cli.flags);
    } else {
        console.error(`> Error: "${cli.input[0]}" isn't a valid URL`);
        process.exit(1);
    }
} else {
    cli.showHelp();
}

valid-url

URI validation functions

Unrecognized
Latest version published 11 years ago

Package Health Score

71 / 100
Full package analysis

Similar packages