How to use normalize-url - 10 common examples

To help you get started, we’ve selected a few normalize-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 GetStream / Winds / api / src / controllers / rss.js View on Github external
exports.post = async (req, res) => {
	const data = req.body || {};
	let normalizedUrl;
	// TODO: refactor this url check in utitlies
	try {
		normalizedUrl = normalizeUrl(data.feedUrl);
	} catch (e) {
		return res.status(400).json({ error: 'Please provide a valid RSS URL.' });
	}
	if (!data.feedUrl || !isURL(normalizedUrl)) {
		return res.status(400).json({ error: 'Please provide a valid RSS URL.' });
	}

	let foundRSS = await discoverRSS(normalizeUrl(data.feedUrl));

	if (!foundRSS.feedUrls.length) {
		return res
			.status(404)
			.json({ error: "We couldn't find any feeds for that RSS feed URL :(" });
	}

	let insertedFeeds = [];
github visualjerk / quill-magic-url / src / index.js View on Github external
normalize (url) {
    if (this.options.normalizeRegularExpression.test(url)) {
      return normalizeUrl(url, this.options.normalizeUrlOptions)
    }
    return url
  }
}
github posthtml / posthtml-cache / src / index.js View on Github external
const setNanoid = url => {
    const id = nanoid();
    const fullUrl = /^[/?]/.test(url) ? `foo.bar${url}` : url;

    if (!isUrl(normalizeUrl(fullUrl))) {
        return url;
    }

    let [uri, query] = fullUrl.split('?');
    query = queryString.parse(query);
    query.v = query.v ? query.v : id;
    query = queryString.stringify(query);

    return `${uri}?${query}`;
};
github garden-io / garden / dashboard / src / components / overview.tsx View on Github external
export function getIngressUrl(ingress: ServiceIngress) {
  return normalizeUrl(format({
    protocol: ingress.protocol,
    hostname: ingress.hostname,
    port: ingress.port,
    pathname: ingress.path,
  }))
}
github raindropio / extensions / src / background / inject / parser.js View on Github external
_getCompactURL(url='') {
		var compact = url

		try{
			compact = normalizeURL(url, {
				normalizeHttps: true,
			})
		}catch(e){}

		return compact.replace(/\?.+$/,'').replace('http://','')
	}
github GetStream / Winds / api / src / controllers / opml.js View on Github external
try {
		isPodcast = await IsPodcastURL(feed.feedUrl);
	} catch (_) {
		throw new Error(`Error opening ${feed.feedUrl}`);
	}

	if (isPodcast) {
		schema = Podcast;
		publicationType = 'podcast';
	} else {
		schema = RSS;
		publicationType = 'rss';
	}

	const feedUrl = normalizeUrl(feed.feedUrl);
	if (!isURL(feedUrl)) {
		throw new Error(`Invalid URL for OPML import ${feedUrl}`);
	}

	return { feed, schema, publicationType, url: feedUrl };
}
github GetStream / Winds / assets / js / components / SuggestedFeeds / index.js View on Github external
render() {

        if (!this.state.displaySuggestion) return null
        if (!this.props.siteUrl) return null

        return(
            <div>
                <li>
                    <div>
                        <svg viewBox="147 15 9 9" height="9px" width="9px">
                            <path fill="#99A9B3" stroke="none" id="X_1" d="M152.45,19.03525 L154.925,16.56025 C155.121,16.36525 155.121,16.04825 154.925,15.85325 L154.218,15.14625 C154.023,14.95125 153.706,14.95125 153.511,15.14625 L151.036,17.62125 L148.561,15.14625 C148.366,14.95125 148.049,14.95125 147.854,15.14625 L147.147,15.85325 C146.951,16.04825 146.951,16.36525 147.147,16.56025 L149.622,19.03525 L147.147,21.51025 C146.951,21.70525 146.951,22.02225 147.147,22.21725 L147.854,22.92425 C148.049,23.11925 148.366,23.11925 148.561,22.92425 L151.036,20.44925 L153.511,22.92425 C153.706,23.11925 154.023,23.11925 154.218,22.92425 L154.925,22.21725 C155.121,22.02125 155.121,21.70525 154.925,21.51025 L152.45,19.03525 Z"></path>
                        </svg>
                    </div>
                    <div>
                        <div>
                            <a title="{this.props.siteName}" href="{normalizeUrl(this.props.siteUrl)}">
                                <img width="32" height="32" src="{this.props.faviconUrl}">
                            </a>
                        </div>
                    </div>
                    <div>
                        <a href="{normalizeUrl(this.props.siteUrl)}">
                            <p>{this.props.siteName}</p>
                        </a>
                        <a data-id="{this.props.feedId}" href="#">
                            Follow
                        </a>
                    </div>
                </li>
            </div>
        )
    }
github GetStream / Winds / api / src / controllers / opml.js View on Github external
feeds = await util.promisify(opmlParser)(upload);
	} catch (e) {
		return res.status(422).json({ error: 'Invalid OPML upload.' });
	}

	for (const feed of feeds) {
		feed.valid = true;

		if (isURL(feed.feedUrl)) {
			feed.feedUrl = normalizeUrl(feed.feedUrl).trim();
		} else {
			feed.valid = false;
		}

		if (isURL(feed.url)) {
			feed.url = normalizeUrl(feed.url);
		}

		feed.favicon = '';
		if (feeds.site && feeds.site.favicon) {
			feed.favicon = feeds.site.favicon;
		}
	}

	const feedIdentities = await Promise.all(
		feeds.map(async (f) => {
			try {
				return { result: await identifyFeedType(f) };
			} catch (err) {
				return { feedUrl: f.feedUrl, error: err.message };
			}
		}),

normalize-url

Normalize a URL

MIT
Latest version published 2 months ago

Package Health Score

80 / 100
Full package analysis

Popular normalize-url functions