Skip to content

Instantly share code, notes, and snippets.

@millette
Last active December 12, 2017 19:46
Show Gist options
  • Save millette/4992b78ea377fd6de9db0ebf16810d2d to your computer and use it in GitHub Desktop.
Save millette/4992b78ea377fd6de9db0ebf16810d2d to your computer and use it in GitHub Desktop.

Moved to https://github.com/joehand/dat-link-resolve

Refering to dats

Trying to tighten up a bit dat-link-resolve (and its dependencies dat-dns and dat-decode). I am noticing a few inconsistencies as I'm writing dat-shell.

Ideally, I'd like to launch dat-shell like this:

$ dat-shell dat://40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5/path4

and have it open the dat at version 5 and change directory to /path4.

Currently dat-shell google-fonts-kewitz.hashbase.io/fonts/ fails somewhere in dat-link-resolve.

Examples

Note that dat-link-resolve also supports other methods, such as detection of dat keys in paths and http headers.

Simplest

  • Plain: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9
  • DNS: pfrazee.hashbase.io

With version

  • Plain: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9+5
  • DNS: pfrazee.hashbase.io+5

With scheme

With path

  • https: 40a7f6b6147ae695bcbcff432f684c7bb5291ea339c28c1755896cdeb80bd2f9/path1
  • dat: pfrazee.hashbase.io/path2

Combinations

Notes

  1. browsers expect http and https schemes with traditional hostname, not a dat key
  2. browsers expect http and https schemes with traditional hostname, no +5 (version) support
@millette
Copy link
Author

millette commented Dec 9, 2017

I added a few more tests to dat-link-resolve.

This one is commented out since it currently fails:

test('resolve hostname with path', function (t) {
  t.plan(2)
  datResolve('beakerbrowser.com/path', function (err, newKey) {
    console.log('HOSTNAMEPATH', err, newKey)
    t.notOk(err, 'not expected error')
    t.ok(newKey, 'is a key')
  })
})

What's strange is that it doesn't produce an error, nor a key...

@millette
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment