How to use the url-parse.default function in url-parse

To help you get started, we’ve selected a few url-parse 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 launchlet / launchlet / os-app / dev-launcher / recipes / TypeURL / main.js View on Github external
import * as _URLParser from 'url-parse';
const URLParser = typeof _URLParser === 'function' ? _URLParser : _URLParser.default;

export const LCHTypeURLCallback = function(inputData) {
	if (typeof inputData !== 'string') {
		// throw new Error('LCHErrorInputInvalid');
		return false
	}

	if (!(new URLParser(inputData)).hostname) {
		return false;
	}

	return true;
};

export const LCHTypeStringCanonicalExampleCallback = function() {
	return 'http://example.com';
github launchlet / launchlet / os-app / dev-launcher / recipes / primitives / URL / main.js View on Github external
import * as _URLParser from 'url-parse';
const URLParser = typeof _URLParser === 'function' ? _URLParser : _URLParser.default;

export const LCHPrimitiveURLCallback = function(inputData) {
	if (typeof inputData !== 'string') {
		// throw new Error('LCHErrorInputInvalid');
		return false;
	}

	if (!(new URLParser(inputData, {})).hostname) { // To parse an input independently of the browser's current URL (e.g. for functionality parity with the library in a Node environment), pass an empty location object as the second parameter
		return false;
	}

	return true;
};

export const LCHPrimitiveStringCanonicalExampleCallback = function() {
	return 'http://example.com';

url-parse

Small footprint URL parser that works seamlessly across Node.js and browser environments

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis

Popular url-parse functions