How to use the valid-url.isUri 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 glennjones / text-autolinker / lib / autolinker.js View on Github external
words = [text];
		if (text.indexOf(' ') > -1) {
			words = text.split(' ');
		}

		// add html links
		i = words.length;
		while (x < i) {
			var cn = options.className,
				word = utils.trim(words[x]);

			// the . is not need for valid url, but is inforced here
			if (word.indexOf('http:') === 0 || word.indexOf('https:') === 0 && word.indexOf('.') > 0) {

				// check url is valid 
				if (validUrl.isUri(word)) {
					if (!out.url) {
						out.url = [];
					}
					expanded = getExpandedUrl(word, options);
					var address = word;
					if (expanded) {
						address = expanded;
						out.url.push({
							match: word,
							expanded: expanded
						});
					} else {
						out.url.push({
							match: word
						});
					}
github IBM / ipfs-social-proof / src / remote-proofs.js View on Github external
formatRedditUrl (url) {
    if (!validUrl.isUri(url)) {
      throw new Error('Valid url is required')
    }

    let parsed = parse(url)
    if (!parsed.hostname === 'www.reddit.com') {
      throw new Error('Url has to use www.reddit.com as host')
    }

    if (url.endsWith('.json')) {
      return url
    } else if (url.endsWith('/')) {
      let urlArr = url.split('/')
      urlArr.pop() // removes the enpty
      return `${urlArr.join('/')}.json`
    } else {
      throw new Error('Url is not correct format for a Reddit proof')
github FlandreDaisuki / rollup-plugin-userscript-metablock / dist / rollup-plugin-userscript-metablock.common.js View on Github external
const isGlobURI = (s) => (/^\/.*\/$/).test(s) || Boolean(validUrl.isUri(s)) || (isString(s) && s.includes('*'));
const isIPv4 = (s) => {
github IBM / ipfs-social-proof / src / remote-proofs.js View on Github external
async getRedditData (url) {
    let rUrl = this.formatRedditUrl(url)

    if (!validUrl.isUri(rUrl)) {
      throw new Error('Valid url is required')
    }
    try {
      return await fetch(rUrl)
        .then((response) => {
          return response.json();
        })
    } catch (ex) {
      console.error(ex)
      return null
    }
  }
github FlandreDaisuki / rollup-plugin-userscript-metablock / dist / rollup-plugin-userscript-metablock.esm.js View on Github external
    const isValidConnect = (v) => isIPv4(v) || isUri(v) || /[\w-]+(\.[\w-]+)+/.test(v) || v === '*';
    if (!val) {
github FlandreDaisuki / rollup-plugin-userscript-metablock / src / meta.js View on Github external
    const isValidConnect = (v) => isIPv4(v) || isUri(v) || /[\w-]+(\.[\w-]+)+/.test(v) || v === '*';
    if (!val) {
github kununu / pact-cli / src / commands.js View on Github external
export function verify (args) {
  const config = getConfig();
  const toValidate = validUrl.isUri(args.PACT_FILE) ? args.PACT_FILE : path.resolve(process.cwd(), args.PACT_FILE);

  const opts = {
    pactUrls: [toValidate],
    providerBaseUrl: args.provider_base_url,
    providerStatesSetupUrl: args.states_setup_url,
  };

  if (config.brokerUser.trim() !== '') {
    Object.assign(opts, {
      pactBrokerUsername: config.brokerUser,
      pactBrokerPassword: config.brokerPassword,
    });
  }

  pact.verifyPacts(opts).then((pactObject) => {
    log('=================================================================================');
github BTWhite / BTWChain / src / core / dapps.js View on Github external
}

        var foundCategory = false;
        for (var i in dappCategory) {
            if (dappCategory[i] == dapp.category) {
                foundCategory = true;
                break;
            }
        }

        if (!foundCategory) {
            return setImmediate(cb, "Unknown dapp category");
        }

        if (dapp.icon) {
            if (!valid_url.isUri(dapp.icon)) {
                return setImmediate(cb, "Invalid icon link");
            }

            var length = dapp.icon.length;

            if (
                dapp.icon.indexOf('.png') != length - 4 &&
                dapp.icon.indexOf('.jpg') != length - 4 &&
                dapp.icon.indexOf('.jpeg') != length - 5
            ) {
                return setImmediate(cb, "Invalid icon file type")
            }

            if (dapp.icon.length > 160) {
                return setImmediate(cb, "Dapp icon url is too long. Maximum is 160 characters");
            }

valid-url

URI validation functions

Unrecognized
Latest version published 11 years ago

Package Health Score

71 / 100
Full package analysis

Similar packages