|
|
@@ -137,11 +137,10 @@ class BankClient {
|
|
|
return uploadResponse.hash;
|
|
|
});
|
|
|
}
|
|
|
- appendBank(bankLink, itemHash) {
|
|
|
+ appendBank(bankAddress, bankTopic, itemHash) {
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
const payload = yield this.makePlaintextPayload(itemHash);
|
|
|
- const { address, topic } = this.parseBankLink(bankLink);
|
|
|
- const topicURL = this.urlBase + '/bank/private/' + encodeURIComponent(address) + '/' + encodeURIComponent(topic);
|
|
|
+ const topicURL = this.urlBase + '/bank/private/' + encodeURIComponent(bankAddress) + '/' + encodeURIComponent(bankTopic);
|
|
|
yield this.webClient.requestJSON({
|
|
|
body: payload,
|
|
|
method: 'PUT',
|
|
|
@@ -187,11 +186,20 @@ class BankClient {
|
|
|
if (!bankLink.startsWith('bank:')) {
|
|
|
throw new Error('address must start with bank:');
|
|
|
}
|
|
|
- const [address, topic] = bankLink.substring(5).split('/');
|
|
|
+ const deprefixed = bankLink.substring(5);
|
|
|
+ let host;
|
|
|
+ let address;
|
|
|
+ let topic;
|
|
|
+ if (deprefixed[0] === '/' && deprefixed[1] === '/') {
|
|
|
+ [host, address, topic] = bankLink.substring(5).split('/');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [address, topic] = bankLink.substring(5).split('/');
|
|
|
+ }
|
|
|
if (!address || !topic) {
|
|
|
throw new Error('cannot parse address and topic');
|
|
|
}
|
|
|
- return { address, topic };
|
|
|
+ return { host, address, topic };
|
|
|
}
|
|
|
}
|
|
|
exports.BankClient = BankClient;
|