0.7.1 • Published 9 years ago

substitute v0.7.1

Weekly downloads
434
License
-
Repository
github
Last release
9 years ago

Substitute

A proxy image server. This is a rewrite version of camo.

Build Status Coverage Status

Installation

Install with npm:

$ npm install substitute -g

Quick Help

$ substitute -h

  Usage: substitute [options]

  Options:

    -b, --bind <port>      The port or unix path to listen
    --host <host>          The hostname to listen [localhost]
    --path <path>          The pathname to listen [null]
    -c, --config <file>    Specify a configuration file
    -r, --redirects <num>  Max redirects allowed, default is 4
    -s, --secret <token>   A secret token to encrypto urls
    -V, --version          Display the version
    -h, --help             Display this help menu

URL Formats

Unlike camo, substitute supports only one URL Format:

http://example.org/<reverse-domain>/<digest>/<image-path>

The <digest> is a 32 character hex encoded HMAC digest with a secret in md5 hash. And the <image-path> should be an ecoded/escaped replaced '/' uri.

http://example.org/moc.dlrowsmuabe.aidem/d42a08bfa19e5b526b0d2d53eb3b106c/picture/Mincemeat/Pimp.jpg

Browser Support

You can get the browser client with component(1):

$ component install lepture/substitute

And generate new src with:

var substitute = require('substitute');
substitute.server = 'https://example.com';
substitute.secret = 'a secret that match the server secret';

var newSrc = substitute.link('http://path/to/image');

// replace all image src
var newHtml = substitute.image(html);

Testing

Test it manally, start a server:

$ substitute

And then visit: this link.

Test it automatically with mocha:

$ make test

You can also test the client part with:

$ make test-client

API

var substitute = require('substitute');
console.log(substitute.version);

substitute.defaults({
    maxRedirects: 5
});

var server = substitute(secret, options);
server.listen(8000)
0.7.1

9 years ago

0.7.0

9 years ago

0.6.2

9 years ago

0.6.1

9 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.3.3

11 years ago

0.3.2

11 years ago

0.3.1

11 years ago

0.3.0

11 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago