Get the last available skylink.

This commit is contained in:
Ivaylo Novakov 2020-08-05 17:32:51 +03:00
parent 651935ea3a
commit 6f408e49c9
No known key found for this signature in database
GPG Key ID: 06B9354AB08BE9C6
1 changed files with 7 additions and 1 deletions

View File

@ -32,7 +32,13 @@ const getDomainRecords = async (name) => {
}; };
const findSkylinkRecord = (records) => { 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) => { const getSkylinkFromRecord = (record) => {