From 6f408e49c93de7c4e9c6b68328997f23bee307ff Mon Sep 17 00:00:00 2001 From: Ivaylo Novakov Date: Wed, 5 Aug 2020 17:32:51 +0300 Subject: [PATCH] Get the last available skylink. --- handshake-api/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/handshake-api/index.js b/handshake-api/index.js index 896514fb..63cd75d7 100644 --- a/handshake-api/index.js +++ b/handshake-api/index.js @@ -32,7 +32,13 @@ const getDomainRecords = async (name) => { }; const findSkylinkRecord = (records) => { - return records?.find(({ txt }) => txt?.some((entry) => isValidSkylink(entry))); + // Find the last one, so people can update their domains in a non-destructive + // way by simply adding a new link. This will also allow keeping links to + // older versions for backwards compatibility. + return records + ?.slice() + .reverse() + .find(({ txt }) => txt?.some((entry) => isValidSkylink(entry))); }; const getSkylinkFromRecord = (record) => {