Skip to content

Commit

Permalink
Merge pull request #26 from h-sugawara/release/v1.1.1
Browse files Browse the repository at this point in the history
Release/v1.1.1
  • Loading branch information
h-sugawara authored Jan 26, 2024
2 parents c0f7f4c + b4ff258 commit 607dd97
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 45 deletions.
13 changes: 6 additions & 7 deletions lib/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ function findOptionalArgs(opts, find) {
}

function getFetchOptions(isCrawler) {
const fetchOptions = {};
const headers = {};
const fetchOptions = {
headers: {
'accept': 'text/html',
},
};

if (typeof isCrawler === 'boolean' && isCrawler) {
headers['user-agent'] = CRAWLER_USER_AGENT;
}

if (Object.keys(headers).length !== 0) {
fetchOptions.headers = headers;
fetchOptions.headers['user-agent'] = CRAWLER_USER_AGENT;
}

return fetchOptions;
Expand Down
66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hexo-tag-ogp-link-preview",
"description": "A Hexo tag plugin for embedding link preview by OpenGraph on article.",
"version": "1.1.0",
"version": "1.1.1",
"license": "MIT",
"author": "Hiroki Sugawara <[email protected]>",
"homepage": "https://blog.chaotic-notes.com/",
Expand All @@ -28,13 +28,13 @@
"test": "jest --verbose --coverage"
},
"devDependencies": {
"eslint": "^8.53.0",
"eslint": "^8.56.0",
"eslint-config-hexo": "^5.0.0",
"eslint-plugin-json": "^3.1.0",
"jest": "^29.7.0"
},
"dependencies": {
"hexo-util": "^3.1.0",
"open-graph-scraper": "^6.3.2"
"hexo-util": "^3.2.0",
"open-graph-scraper": "^6.3.3"
}
}
4 changes: 3 additions & 1 deletion test/parameters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('parameters', () => {
url: args[0],
fetchOptions: {
headers: {
'accept': 'text/html',
'user-agent': 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/112.0.0.0 Safari/537.36',
},
},
Expand Down Expand Up @@ -43,6 +44,7 @@ describe('parameters', () => {
url: args[0],
fetchOptions: {
headers: {
'accept': 'text/html',
'user-agent': 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Chrome/112.0.0.0 Safari/537.36',
},
},
Expand All @@ -60,7 +62,7 @@ describe('parameters', () => {

expect(getParameters(args, fallbackText, config)).toEqual(
{
scrape: { url: args[0], fetchOptions: {} },
scrape: { url: args[0], fetchOptions: { headers: { accept: 'text/html' } } },
generate: { target: '_blank', rel: 'nofollow', loading: 'lazy', descriptionLength, className, fallbackText },
}
);
Expand Down

0 comments on commit 607dd97

Please sign in to comment.