How to use isurl - 6 common examples

To help you get started, we’ve selected a few isurl 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 stevenvachon / broken-link-checker / lib / public / UrlChecker.js View on Github external
enqueue(url, customData, auth={})
	{
		let link;

		// Undocumented internal use: `enqueue(Link)`
		if (url instanceof Link)
		{
			link = url;
		}
		// Documented use: `enqueue(URL)`
		else if (isURL.lenient(url))
		{
			link = new Link().resolve(url);
		}
		else
		{
			throw new TypeError("Invalid URL");
		}

		const id = this.#linkQueue.enqueue(link.get(REBASED_URL), { auth, customData, link });

		this.emit(QUEUE_EVENT);

		return id;
	}
github Hackdromeda / BugBrowser / node_modules / got / index.js View on Github external
if (!is.string(url) && !is.object(url)) {
		throw new TypeError(`Parameter \`url\` must be a string or object, not ${is(url)}`);
	} else if (is.string(url)) {
		url = url.replace(/^unix:/, 'http://$&');

		try {
			decodeURI(url);
		} catch (err) {
			throw new Error('Parameter `url` must contain valid UTF-8 character sequences');
		}

		url = urlParseLax(url);
		if (url.auth) {
			throw new Error('Basic authentication must be done with the `auth` option');
		}
	} else if (isURL.lenient(url)) {
		url = urlToOptions(url);
	}

	opts = Object.assign(
		{
			path: '',
			retries: 2,
			cache: false,
			decompress: true,
			useElectronNet: false,
			throwHttpErrors: true
		},
		url,
		{
			protocol: url.protocol || 'http:' // Override both null/undefined with default protocol
		},
github stevenvachon / broken-link-checker / lib / internal / getRobotsTxt.js View on Github external
export default async (url, auth, cache, options) =>
{
	if (!isURL.lenient(url))
	{
		throw new TypeError(BLC_INVALID);
	}
	else
	{
		url = new URL(url);
		url.hash = "";
		url.pathname = "/robots.txt";
		url.search = "";

		const {stream} = await requestHTTP(url, auth, GET_METHOD, cache, options);

		// @todo https://github.com/tc39/proposal-pipeline-operator
		return guard(await parse(stream));
	}
};
github sx1989827 / DOClever / node_modules / got / index.js View on Github external
if (!is.string(url) && !is.object(url)) {
		throw new TypeError(`Parameter \`url\` must be a string or object, not ${is(url)}`);
	} else if (is.string(url)) {
		url = url.replace(/^unix:/, 'http://$&');

		try {
			decodeURI(url);
		} catch (err) {
			throw new Error('Parameter `url` must contain valid UTF-8 character sequences');
		}

		url = urlParseLax(url);
		if (url.auth) {
			throw new Error('Basic authentication must be done with the `auth` option');
		}
	} else if (isURL.lenient(url)) {
		url = urlToOptions(url);
	}

	opts = Object.assign(
		{
			path: '',
			retries: 2,
			cache: false,
			decompress: true,
			useElectronNet: false,
			throwHttpErrors: true
		},
		url,
		{
			protocol: url.protocol || 'http:' // Override both null/undefined with default protocol
		},
github kevva / caw / index.js View on Github external
module.exports = (proxy, opts) => {
	proxy = proxy || getProxy();
	opts = Object.assign({}, opts);

	if (typeof proxy === 'object') {
		opts = proxy;
		proxy = getProxy();
	}

	if (!proxy) {
		return null;
	}

	proxy = isurl.lenient(proxy) ? urlToOptions(proxy) : url.parse(proxy);

	const uriProtocol = opts.protocol === 'https' ? 'https' : 'http';
	const proxyProtocol = proxy.protocol === 'https:' ? 'Https' : 'Http';
	const port = proxy.port || (proxyProtocol === 'Https' ? 443 : 80);
	const method = `${uriProtocol}Over${proxyProtocol}`;

	delete opts.protocol;

	return tunnelAgent[method](Object.assign({
		proxy: {
			port,
			host: proxy.hostname,
			proxyAuth: proxy.auth
		}
	}, opts));
};
github stevenvachon / limited-request-queue / lib / index.js View on Github external
enqueue(url, data, options)
	{
		if (!isURL.lenient(url))
		{
			throw new TypeError("Invalid URL");
		}
		else
		{
			const hostKey = normalizeURL(url, this.#options, options);
			const id = this.#idCounter++;

			this.#items[id] = { active:false, data, hostKey, id, options, url };
			this.#priorityQueue.push(id);

			this.#maybeStartNext();

			return id;
		}
	}

isurl

Determines whether a value is a WHATWG URL.

MIT
Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis

Popular isurl functions