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

react-native-link-preview

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-link-preview - npm Package Compare versions

Comparing version 1.3.5 to 1.3.6

34

index.js

@@ -7,3 +7,2 @@ /**

const urlObj = require('url');
const fetch = require('cross-fetch').fetch;
require('es6-promise').polyfill();

@@ -30,9 +29,14 @@

if (detectedUrl) {
fetch(detectedUrl)
.then(function(response) {
var request = new XMLHttpRequest();
request.onreadystatechange = (e) => {
if (request.readyState !== 4) {
return;
}
if (request.status === 200) {
// get final URL (after any redirects)
const finalUrl = response.url;
const finalUrl = request.responseURL;
// get content type of response
var contentType = findById(response.headers, 'content-type');
let contentType = findById(request.responseHeaders, 'content-type');
if (!contentType) {

@@ -52,8 +56,5 @@ return reject({ error: 'React-Native-Link-Preview: Could not extract content type for URL.' });

resolve(parseVideoResponse(finalUrl, contentType));
} else if (contentType && CONSTANTS.REGEX_CONTENT_TYPE_TEXT.test(contentType)) {
response.text()
.then(function(text) {
resolve(parseTextResponse(text, finalUrl, options || {}, contentType));
});
} else if (contentType && CONSTANTS.REGEX_CONTENT_TYPE_APPLICATION.test(contentType)) {
} else if (contentType && REGEX_CONTENT_TYPE_TEXT.test(contentType)) {
resolve(parseTextResponse(request._response, finalUrl, options || {}, contentType));
} else if (contentType && REGEX_CONTENT_TYPE_APPLICATION.test(contentType)) {
resolve(parseApplicationResponse(finalUrl, contentType));

@@ -63,4 +64,11 @@ } else {

}
})
.catch(function(error) { reject({ error: error }) });
} else {
reject({
error: 'React-Native-Link-Preview: Could not fetch provided link'
})
}
};
request.open('GET', detectedUrl);
request.send();
} else {

@@ -67,0 +75,0 @@ reject({

{
"name": "react-native-link-preview",
"version": "1.3.5",
"version": "1.3.6",
"description": "",

@@ -10,3 +10,3 @@ "main": "index.js",

"keywords": [
"react-native"
"react-native", "javascript", "link", "url"
],

@@ -19,3 +19,2 @@ "author": "Oscar Franco",

"cheerio-without-node-native": "^0.20.1",
"cross-fetch": "0.0.8",
"es6-promise": "^4.2.4",

@@ -22,0 +21,0 @@ "url": "^0.11.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