@galoymoney/client
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -64,3 +64,2 @@ module.exports = { | ||
"max-depth": ["error", { max: 3 }], | ||
"max-lines-per-function": ["error", { max: 200 }], | ||
"max-lines": ["error", { max: 500 }], | ||
@@ -67,0 +66,0 @@ "max-nested-callbacks": ["error", { max: 5 }], |
@@ -162,8 +162,18 @@ "use strict"; | ||
var getProtocolAndData = function (destination) { | ||
var _a; | ||
// input might start with 'lightning:', 'bitcoin:' | ||
var split = destination.split(":"); | ||
var protocol = split[1] ? split[0].toLocaleLowerCase() : ""; | ||
var destinationWithoutProtocol = (_a = split[1]) !== null && _a !== void 0 ? _a : split[0]; | ||
return { protocol: protocol, destinationWithoutProtocol: destinationWithoutProtocol }; | ||
if (destination.toLocaleLowerCase().startsWith("lightning:")) { | ||
return { | ||
protocol: "lightning", | ||
destinationWithoutProtocol: destination.slice(10), | ||
}; | ||
} | ||
if (destination.toLocaleLowerCase().startsWith("bitcoin:")) { | ||
return { | ||
protocol: "bitcoin", | ||
destinationWithoutProtocol: destination.slice(8), | ||
}; | ||
} | ||
return { | ||
protocol: "", | ||
destinationWithoutProtocol: destination, | ||
}; | ||
}; | ||
@@ -191,3 +201,3 @@ var getPaymentType = function (_a) { | ||
} | ||
var handle = protocol.match(/^(http|\/\/)/iu) | ||
var handle = destinationWithoutProtocol.match(/^(http|\/\/)/iu) | ||
? destinationWithoutProtocol.split("/")[destinationWithoutProtocol.split("/").length - 1] | ||
@@ -201,8 +211,8 @@ : destinationWithoutProtocol; | ||
var getIntraLedgerPayResponse = function (_a) { | ||
var protocol = _a.protocol, destinationWithoutProtocol = _a.destinationWithoutProtocol, destination = _a.destination, lnAddressDomains = _a.lnAddressDomains; | ||
var destinationWithoutProtocol = _a.destinationWithoutProtocol, destination = _a.destination, lnAddressDomains = _a.lnAddressDomains; | ||
var paymentType = exports.PaymentType.Intraledger; | ||
var handle = protocol.match(/^(http|\/\/)/iu) | ||
var handle = destinationWithoutProtocol.match(/^(http|\/\/)/iu) | ||
? destinationWithoutProtocol.split("/")[destinationWithoutProtocol.split("/").length - 1] | ||
: destinationWithoutProtocol; | ||
if (protocol.match(/^(http|\/\/)/iu)) { | ||
if (destinationWithoutProtocol.match(/^(http|\/\/)/iu)) { | ||
var domain_1 = new URL(destination).hostname; | ||
@@ -238,3 +248,2 @@ if (!lnAddressDomains.find(function (lnAddressDomain) { return lnAddressDomain === domain_1; })) { | ||
return getIntraLedgerPayResponse({ | ||
protocol: "", | ||
destinationWithoutProtocol: username, | ||
@@ -398,3 +407,2 @@ lnAddressDomains: lnAddressDomains, | ||
return getIntraLedgerPayResponse({ | ||
protocol: protocol, | ||
destinationWithoutProtocol: destinationWithoutProtocol, | ||
@@ -401,0 +409,0 @@ destination: destination, |
{ | ||
"name": "@galoymoney/client", | ||
"main": "dist/index.js", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/galoymoney/galoy-client", |
62176
701