Socket
Socket
Sign inDemoInstall

share-text-to-whatsapp

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

4

CHANGELOG.md
# Changelog
### 1.0.2 (27 Aug 2019)
* Use `try/catch` to handle `navigator.share` Promise rejection.
* Changed `getWhatsAppBaseUrl` implementation to only use `whatsapp://send` on Android devices.
### 1.0.0 (23 Aug 2019)

@@ -4,0 +8,0 @@

2

index.d.ts

@@ -10,3 +10,3 @@ export declare const shareTextToWhatsApp: (text: string) => void;

declare type Fallback = () => void;
export declare const shareTextViaNativeSharing: (data: ShareData, fallbackFunction?: Fallback | undefined) => void;
export declare const shareTextViaNativeSharing: (data: ShareData, fallbackFunction?: Fallback | undefined) => Promise<void>;
export {};
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -16,7 +24,7 @@ const util_1 = require("./util");

};
exports.shareTextViaNativeSharing = (data, fallbackFunction) => {
if (exports.hasNativeSharingSupport()) {
navigator.share(data);
exports.shareTextViaNativeSharing = (data, fallbackFunction) => __awaiter(this, void 0, void 0, function* () {
try {
yield navigator.share(data);
}
else {
catch (err) {
if (typeof fallbackFunction === 'function') {

@@ -26,2 +34,2 @@ fallbackFunction();

}
};
});
{
"name": "share-text-to-whatsapp",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const isIOSDevice = () => {
const iDevices = ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'];
if (navigator) {
return !!navigator.platform && iDevices.indexOf(navigator.platform) !== -1;
}
return false;
// The client user agent string.
// Lowercase, so we can use the more efficient indexOf(), instead of Regex
const userAgent = window.navigator.userAgent.toLowerCase();
const isWindows = () => {
return userAgent.indexOf('windows') !== -1;
};
const IPAD_MAX_WIDTH = '1024px';
const isAndroid = () => {
return !isWindows() && userAgent.indexOf('android') !== -1;
};
exports.getWhatsAppBaseUrl = () => {
let link = `https://wa.me/`;
if (isIOSDevice()) {
try {
const isIPadOrMobile = window.matchMedia(`(max-width: ${IPAD_MAX_WIDTH})`).matches;
if (isIPadOrMobile) {
link = `whatsapp://send`;
}
}
catch (err) {
link = `whatsapp://send`;
}
if (isAndroid()) {
// use this link for android devices
link = `whatsapp://send`;
}

@@ -24,0 +18,0 @@ return link;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc