Skip to content

Commit

Permalink
Merge 0e39547 into e4065e0
Browse files Browse the repository at this point in the history
  • Loading branch information
ndaidong committed Jul 1, 2023
2 parents e4065e0 + 0e39547 commit b279218
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on: [push, pull_request]
jobs:
test:

runs-on: ubuntu-22.04
runs-on: ubuntu-latest

strategy:
matrix:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ console.log('Run article-extractor with proxy:', proxy)
console.log(art)
```

For more info about [https-proxy-agent](https://www.npmjs.com/package/https-proxy-agent), check [its repo](https://github.com/TooTallNate/proxy-agents).

For more info about proxy authentication, please refer [HTTP authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication)

For a deeper customization, you can consider using [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) to replace `fetch` behaviors with your own handlers.
Expand Down
2 changes: 1 addition & 1 deletion dist/article-extractor.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/article-extractor.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dist/cjs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export interface FetchOptions {
* default: null
*/
proxy?: ProxyConfig;

/**
* http proxy agent
* default: null
*/
agent?: object;
}

export interface ArticleData {
Expand Down
6 changes: 6 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export interface FetchOptions {
* default: null
*/
proxy?: ProxyConfig;

/**
* http proxy agent
* default: null
*/
agent?: object;
}

export interface ArticleData {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"@types/sanitize-html": "^2.9.0",
"esbuild": "^0.18.10",
"eslint": "^8.44.0",
"https-proxy-agent": "^7.0.0",
"jest": "^29.5.0",
"nock": "^13.3.1"
},
Expand Down
4 changes: 2 additions & 2 deletions src/utils/extractWithReadability.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Readability } from '@mozilla/readability'
import { DOMParser } from 'linkedom'
import { isString } from 'bellajs'

export default (html, inputUrl = '') => {
export default (html, url = '') => {
if (!isString(html)) {
return null
}
const doc = new DOMParser().parseFromString(html, 'text/html')
const base = doc.createElement('base')
base.setAttribute('href', inputUrl)
base.setAttribute('href', url)
doc.head.appendChild(base)
const reader = new Readability(doc, {
keepClasses: true,
Expand Down

0 comments on commit b279218

Please sign in to comment.