How to use compare-urls - 1 common examples

To help you get started, we’ve selected a few compare-urls 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 plibither8 / refined-hacker-news / src / features / show-similar-submissions.js View on Github external
const safeStoryLink = encodeURI(storyLink);

		const results = [];
		const rawResults = await fetch(API_URL + safeStoryLink).then(res => res.json()).then(obj => obj.hits);

		if (!rawResults) {
			return resolve(results);
		}

		for (const result of rawResults) {
			// eslint-disable-next-line eqeqeq
			if (result.objectID == metadata.item.id) {
				continue;
			}

			if (!result.url || !compareUrls(result.url.split('://').pop(), storyLink)) {
				continue;
			}

			if (!metadata.options.showDiscussionsWithNoComments && result.num_comments === 0) {
				continue;
			}

			const date = new Date(result.created_at);
			const renderedDate = `${monthNames[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;

			results.push({
				link: `https://news.ycombinator.com/item?id=${result.objectID}`,
				title: result.title,
				date: renderedDate,
				comments: result.num_comments,
				points: result.points

compare-urls

Compare URLs by first normalizing them

MIT
Latest version published 1 year ago

Package Health Score

57 / 100
Full package analysis

Popular compare-urls functions