Skip to content

Commit

Permalink
Follow redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkMacKaywa authored Mar 31, 2020
1 parent 2c0fb34 commit 3ad7592
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions background/dat-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export function resolveName(host) {
if (wellKnownCache.has(host)) {
resolve(Promise.resolve(wellKnownCache.get(host)));
}
fetch(`https://${host}/.well-known/dat`, { redirect: 'manual' }).then((resp) => {
if (resp.ok) {
fetch(`https://${host}/.well-known/dat`, { redirect: 'follow' }).then((resp) => {
if (resp.ok && new URL(resp.url).protocol == 'https:') {
return resp.text().then(text => {
try {
return /^dat:\/\/([0-9a-f]{64})/i.exec(text.split('/n')[0])[1];
Expand All @@ -27,4 +27,4 @@ export function resolveName(host) {
resolve(address);
});
});
}
}

0 comments on commit 3ad7592

Please sign in to comment.