Giter Site home page Giter Site logo

dat-href's Introduction

dat-href

An easy way to get an https:// or dat:// url depending upon environment.

npm i dat-href --save

Usage

Simply require the module, which exposes a single function always returning a string. The first argument is the http url, the second is the dat url.

var href = require('dat-href')
href('https://enoki.site', 'dat://26232fd9e3b7683cabe91fff04ca43cf65c59ce888be89d3635fea9d3a02a6f2')

It’s also possible to use an object:

href({
  http: 'https://enoki.site',
  dat: 'dat://26232fd9e3b7683cabe91fff04ca43cf65c59ce888be89d3635fea9d3a02a6f2'
})

Say you’re linking to a site which is available over http and dat using the .well-known/dat method. All you need to do is provide a single url to the site and it’ll swap the protocol for you.

href('https://enoki.site')
href('dat://enoki.site')

Sometimes when working with a cms you’ll have http and dat keys

Testing

npm run test

dat-href's People

Contributors

jondashkyle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.