Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rss-url-finder

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rss-url-finder - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4-1

index.ts

37

dist/index.js

@@ -33,27 +33,30 @@ "use strict";

function findRss(html) {
var _a;
const rssFeed = [];
const rssSources = [];
for (const type of types_1.TYPES) {
const domain = (0, utils_1.getDomainName)(html);
for (const search of html.querySelectorAll(`*[type="${type}"]`)) {
const { title, href } = search.attrs;
let domain = (_a = html.querySelector(`link[rel="canonical"]`)) === null || _a === void 0 ? void 0 : _a.attrs.href;
if (domain) {
const { hostname, protocol } = new URL(domain);
domain = `${protocol}//${hostname}`;
let url = '';
try {
new URL(href);
url = href;
}
catch (error) {
url = new URL(href, domain).toString();
}
rssSources.push((0, utils_1.newRssSource)({
name: title,
url
}));
}
let url = '';
try {
new URL(href);
url = href;
else {
rssSources.push((0, utils_1.newRssSource)({
name: title,
url: href
}));
}
catch (error) {
url = new URL(href, domain).toString();
}
rssFeed.push((0, utils_1.newRssSource)({
name: title,
url
}));
}
}
return rssFeed;
return rssSources;
}
import { RssSource } from "./types";
import type { HTMLElement } from 'node-html-parser';
export declare function newRssSource({ name, url }: RssSource): RssSource;

@@ -6,1 +7,2 @@ export declare function getHtmlBody(url: string, options?: RequestInit): Promise<string>;

export declare function guessRSSfromUrl(url: string): Promise<RssSource[]>;
export declare function getDomainName(html: HTMLElement): string | undefined;

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.guessRSSfromUrl = exports.generateGuesses = exports.getHtmlBody = exports.newRssSource = void 0;
exports.getDomainName = exports.guessRSSfromUrl = exports.generateGuesses = exports.getHtmlBody = exports.newRssSource = void 0;
const types_1 = require("./types");

@@ -62,1 +62,17 @@ function newRssSource({ name, url }) {

exports.guessRSSfromUrl = guessRSSfromUrl;
function getDomainName(html) {
var _a;
let domain = (_a = html.querySelector(`link[rel="canonical"]`)) === null || _a === void 0 ? void 0 : _a.attrs.href;
if (domain) {
try {
const { hostname, protocol } = new URL(domain);
domain = `${protocol}//${hostname}`;
return domain;
}
catch (error) {
return undefined;
}
}
return undefined;
}
exports.getDomainName = getDomainName;
{
"name": "rss-url-finder",
"version": "0.0.3",
"version": "0.0.4-1",
"description": " A javascript/typescript library to search RSS feed via URL or HTML body ",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -60,7 +60,7 @@ # RSS URL Finder

// name: 'Dev-Academy.com - Web security | Testing & automation | Application architecture',
// url: '/rss2.xml'
// url: 'https://dev-academy.com/rss2.xml'
// },
// {
// name: 'Dev-Academy.com - Web security | Testing & automation | Application architecture',
// url: '/atom.xml'
// url: 'https://dev-academy.com/atom.xml'
// }

@@ -67,0 +67,0 @@ // ]

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc