Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rbren/rss-parser
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: feedspub/rss-parser
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 30, 2020

  1. init requestOptions passthrough

    timqian committed Apr 30, 2020
    Copy the full SHA
    708e519 View commit details
  2. add description

    timqian committed Apr 30, 2020
    Copy the full SHA
    0ae7dc5 View commit details
  3. update readme

    timqian committed Apr 30, 2020
    Copy the full SHA
    3011725 View commit details

Commits on May 3, 2020

  1. add RequestOptions types

    timqian committed May 3, 2020
    Copy the full SHA
    b0dc4d5 View commit details
Showing with 17 additions and 0 deletions.
  1. +13 −0 README.md
  2. +2 −0 index.d.ts
  3. +2 −0 lib/parser.js
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -204,6 +204,19 @@ with `options.maxRedirects`.
let parser = new Parser({maxRedirects: 100});
```

### Request passthrough
`rss-parser` uses [http](https://nodejs.org/docs/latest/api/http.html#http_http_get_url_options_callback)/[https](https://nodejs.org/docs/latest/api/https.html#https_https_get_url_options_callback) module
to do requests. You can pass [these options](https://nodejs.org/docs/latest/api/https.html#https_https_request_options_callback)
to `http.get()`/`https.get()` by specifying `options.requestOptions`:

e.g. to allow unauthorized certificate
```js
let parser = new Parser({
requestOptions: {
rejectUnauthorized: false
}
});
```

## Contributing
Contributions are welcome! If you are adding a feature or fixing a bug, please be sure to add a [test case](https://github.com/bobby-brennan/rss-parser/tree/master/test/input)
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Options } from 'xml2js';
import { RequestOptions } from 'https';

declare namespace Parser {
export interface Headers {
@@ -15,6 +16,7 @@ declare namespace Parser {

export interface ParserOptions {
readonly xml2js?: Options;
readonly requestOptions?: RequestOptions;
readonly headers?: Headers;
readonly defaultRSS?: number;
readonly maxRedirects?: number;
2 changes: 2 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ class Parser {
options.customFields = options.customFields || {};
options.customFields.item = options.customFields.item || [];
options.customFields.feed = options.customFields.feed || [];
options.requestOptions = options.requestOptions || {};
if (!options.maxRedirects) options.maxRedirects = DEFAULT_MAX_REDIRECTS;
if (!options.timeout) options.timeout = DEFAULT_TIMEOUT;
this.options = options;
@@ -81,6 +82,7 @@ class Parser {
hostname: urlParts.hostname,
port: urlParts.port,
path: urlParts.path,
...this.options.requestOptions,
}, (res) => {
if (this.options.maxRedirects && res.statusCode >= 300 && res.statusCode < 400 && res.headers['location']) {
if (redirectCount === this.options.maxRedirects) {