Skip to content

Commit

Permalink
Merge pull request #173 from extractus/dev
Browse files Browse the repository at this point in the history
v3.1.10
  • Loading branch information
ndaidong committed Jun 14, 2023
2 parents f22ad93 + c19da10 commit 624a12a
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 26 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Extract oEmbed content from given URL.
[![CI test](https://github.com/extractus/oembed-extractor/workflows/ci-test/badge.svg)](https://github.com/extractus/oembed-extractor/actions)
[![Coverage Status](https://coveralls.io/repos/github/extractus/oembed-extractor/badge.svg)](https://coveralls.io/github/extractus/oembed-extractor)
![CodeQL](https://github.com/extractus/oembed-extractor/workflows/CodeQL/badge.svg)
[![CodeFactor](https://www.codefactor.io/repository/github/extractus/oembed-extractor/badge)](https://www.codefactor.io/repository/github/extractus/oembed-extractor)

## Intro

Expand Down
75 changes: 68 additions & 7 deletions dist/cjs/oembed-extractor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @extractus/oembed-extractor@3.1.9, by @extractus - built with esbuild at 2023-03-28T03:30:23.153Z - published under MIT license
// @extractus/oembed-extractor@3.1.10, by @extractus - built with esbuild at 2023-06-14T14:23:09.551Z - published under MIT license
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
Expand Down Expand Up @@ -1805,9 +1805,9 @@ var require_public_api = __commonJS({
}
});

// node_modules/.pnpm/node-fetch@2.6.7/node_modules/node-fetch/lib/index.js
// node_modules/.pnpm/node-fetch@2.6.11/node_modules/node-fetch/lib/index.js
var require_lib2 = __commonJS({
"node_modules/.pnpm/node-fetch@2.6.7/node_modules/node-fetch/lib/index.js"(exports, module2) {
"node_modules/.pnpm/node-fetch@2.6.11/node_modules/node-fetch/lib/index.js"(exports, module2) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function _interopDefault(ex) {
Expand Down Expand Up @@ -2802,6 +2802,11 @@ var require_lib2 = __commonJS({
const dest = new URL$1(destination).hostname;
return orig === dest || orig[orig.length - dest.length - 1] === "." && orig.endsWith(dest);
};
var isSameProtocol = function isSameProtocol2(destination, original) {
const orig = new URL$1(original).protocol;
const dest = new URL$1(destination).protocol;
return orig === dest;
};
function fetch2(url, opts) {
if (!fetch2.Promise) {
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
Expand All @@ -2817,7 +2822,7 @@ var require_lib2 = __commonJS({
let error = new AbortError("The user aborted a request.");
reject(error);
if (request.body && request.body instanceof Stream.Readable) {
request.body.destroy(error);
destroyStream(request.body, error);
}
if (!response || !response.body)
return;
Expand Down Expand Up @@ -2852,8 +2857,31 @@ var require_lib2 = __commonJS({
}
req.on("error", function(err) {
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, "system", err));
if (response && response.body) {
destroyStream(response.body, err);
}
finalize();
});
fixResponseChunkedTransferBadEnding(req, function(err) {
if (signal && signal.aborted) {
return;
}
if (response && response.body) {
destroyStream(response.body, err);
}
});
if (parseInt(process.version.substring(1)) < 14) {
req.on("socket", function(s) {
s.addListener("close", function(hadError) {
const hasDataListener = s.listenerCount("data") > 0;
if (response && hasDataListener && !hadError && !(signal && signal.aborted)) {
const err = new Error("Premature close");
err.code = "ERR_STREAM_PREMATURE_CLOSE";
response.body.emit("error", err);
}
});
});
}
req.on("response", function(res) {
clearTimeout(reqTimeout);
const headers = createHeadersLenient(res.headers);
Expand Down Expand Up @@ -2904,7 +2932,7 @@ var require_lib2 = __commonJS({
timeout: request.timeout,
size: request.size
};
if (!isDomainOrSubdomain(request.url, locationURL)) {
if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
for (const name of ["authorization", "www-authenticate", "cookie", "cookie2"]) {
requestOpts.headers.delete(name);
}
Expand Down Expand Up @@ -2965,6 +2993,12 @@ var require_lib2 = __commonJS({
response = new Response(body, response_options);
resolve(response);
});
raw.on("end", function() {
if (!response) {
response = new Response(body, response_options);
resolve(response);
}
});
return;
}
if (codings == "br" && typeof zlib.createBrotliDecompress === "function") {
Expand All @@ -2979,6 +3013,33 @@ var require_lib2 = __commonJS({
writeToStream(req, request);
});
}
function fixResponseChunkedTransferBadEnding(request, errorCallback) {
let socket;
request.on("socket", function(s) {
socket = s;
});
request.on("response", function(response) {
const headers = response.headers;
if (headers["transfer-encoding"] === "chunked" && !headers["content-length"]) {
response.once("close", function(hadError) {
const hasDataListener = socket.listenerCount("data") > 0;
if (hasDataListener && !hadError) {
const err = new Error("Premature close");
err.code = "ERR_STREAM_PREMATURE_CLOSE";
errorCallback(err);
}
});
}
});
}
function destroyStream(stream, err) {
if (stream.destroy) {
stream.destroy(err);
} else {
stream.emit("error", err);
stream.end();
}
}
fetch2.isRedirect = function(code) {
return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
};
Expand All @@ -2993,9 +3054,9 @@ var require_lib2 = __commonJS({
}
});

// node_modules/.pnpm/cross-fetch@3.1.5/node_modules/cross-fetch/dist/node-ponyfill.js
// node_modules/.pnpm/cross-fetch@3.1.6/node_modules/cross-fetch/dist/node-ponyfill.js
var require_node_ponyfill = __commonJS({
"node_modules/.pnpm/cross-fetch@3.1.5/node_modules/cross-fetch/dist/node-ponyfill.js"(exports, module2) {
"node_modules/.pnpm/cross-fetch@3.1.6/node_modules/cross-fetch/dist/node-ponyfill.js"(exports, module2) {
var nodeFetch = require_lib2();
var realFetch = nodeFetch.default || nodeFetch;
var fetch2 = function(url, options) {
Expand Down
2 changes: 1 addition & 1 deletion dist/cjs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@extractus/oembed-extractor",
"version": "3.1.9",
"version": "3.1.10",
"main": "./@extractus/oembed-extractor.js"
}
2 changes: 1 addition & 1 deletion dist/oembed-extractor.esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @extractus/oembed-extractor@3.1.9, by @extractus - built with esbuild at 2023-03-28T03:30:23.153Z - published under MIT license
// @extractus/oembed-extractor@3.1.10, by @extractus - built with esbuild at 2023-06-14T14:23:09.551Z - published under MIT license

// src/utils/linker.js
var isValid = (url = "") => {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.1.9",
"version": "3.1.10",
"name": "@extractus/oembed-extractor",
"description": "Get oEmbed data from given URL.",
"homepage": "https://github.com/extractus/oembed-extractor",
Expand Down Expand Up @@ -36,13 +36,13 @@
"reset": "node reset"
},
"dependencies": {
"cross-fetch": "^3.1.5"
"cross-fetch": "^3.1.6"
},
"devDependencies": {
"esbuild": "^0.17.14",
"eslint": "^8.36.0",
"esbuild": "^0.18.2",
"eslint": "^8.42.0",
"jest": "^29.5.0",
"nock": "^13.3.0"
"nock": "^13.3.1"
},
"keywords": [
"oembed",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/providers.latest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// provider data, synchronized at 2023-03-28T03:23:00.248Z
// provider data, synchronized at 2023-06-14T14:23:01.829Z

/* eslint-disable */

Expand Down
28 changes: 18 additions & 10 deletions src/utils/providers.prev.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// provider data, synchronized at 2023-01-11T02:27:50.456Z
// provider data, synchronized at 2023-03-28T03:23:00.248Z

/* eslint-disable */

Expand Down Expand Up @@ -148,6 +148,12 @@ export const providers = [
],
"e": "backtracks.fm/oembed"
},
{
"s": [
"beams\\.fm/*"
],
"e": "api.beams.fm/oEmbed"
},
{
"s": [],
"e": "www.beautiful.ai/api/oembed"
Expand Down Expand Up @@ -213,13 +219,6 @@ export const providers = [
],
"e": "minesweeper.today/api/oembed"
},
{
"s": [
"www-catapult-app\\.sandbox\\.hs-sites\\.com/video-page*",
"www-catapult\\.app/video-page*"
],
"e": "www.catapult.app/_hcms/api/video/oembed"
},
{
"s": [
"img\\.catbo\\.at/*"
Expand Down Expand Up @@ -857,9 +856,12 @@ export const providers = [
"*\\.jovian\\.ml/*",
"jovian\\.ai/*",
"jovian\\.ai/viewer*",
"*\\.jovian\\.ai/*"
"*\\.jovian\\.ai/*",
"jovian\\.com/*",
"jovian\\.com/viewer*",
"*\\.jovian\\.com/*"
],
"e": "api.jovian.ai/oembed.json"
"e": "api.jovian.com/oembed.json"
},
{
"s": [
Expand Down Expand Up @@ -1056,6 +1058,12 @@ export const providers = [
],
"e": "www.mixcloud.com/oembed/"
},
{
"s": [
"mixpanel\\.com/*"
],
"e": "mixpanel.com/api/app/embed/oembed/"
},
{
"s": [
"www\\.mobypicture\\.com/user/*/view/*",
Expand Down

0 comments on commit 624a12a

Please sign in to comment.