-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dnslink): redirect to IPNS path
Closes #298
- Loading branch information
Showing
2 changed files
with
51 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict' | ||
/* eslint-env webextensions, mocha */ | ||
// eslint-disable-next-line no-unused-vars | ||
/* globals sinon, initStates, optionDefaults, should, state, redirectToIpnsPath, URL */ | ||
|
||
var sandbox | ||
|
||
// https://github.com/ipfs/ipfs-companion/issues/303 | ||
describe('DNSLINK', function () { | ||
beforeEach(() => { | ||
browser.flush() | ||
sandbox = sinon.sandbox.create() | ||
browser.storage.local.get.returns(Promise.resolve(optionDefaults)) | ||
// reset states | ||
initStates(optionDefaults) | ||
// stub default state for most of tests | ||
// redirect by default -- makes test code shorter | ||
state.peerCount = 1 | ||
state.redirect = true | ||
state.catchUnhandledProtocols = true | ||
state.gwURLString = 'http://127.0.0.1:8080' | ||
}) | ||
|
||
afterEach(() => { | ||
sandbox.restore() | ||
browser.flush() | ||
}) | ||
|
||
describe('redirectToIpnsPath(url)', function () { | ||
it('should return IPNS path at a custom gateway', function () { | ||
const url = new URL('http://ipfs.git.sexy/sketches/ipld_intro.html?a=b#c=d') | ||
redirectToIpnsPath(url).redirectUrl.should.equal('http://127.0.0.1:8080/ipns/ipfs.git.sexy/sketches/ipld_intro.html?a=b#c=d') | ||
}) | ||
}) | ||
}) |