# substitute

> A proxy image server

Latest version **0.7.1** (published 2014-12-24) · 0 weekly downloads

## Install

```sh
npm install substitute
pnpm add substitute
yarn add substitute
bun add substitute
```

Provides the command `substitute`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2014-12-24 |
| First published | 2013-07-02 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Hsiaoming Yang |
| Maintainers | lepture |
| Keywords | proxy, image, server |

## Links

- npm: https://www.npmjs.com/package/substitute
- Repository: https://github.com/lepture/substitute
- Issues: https://github.com/lepture/substitute/issues
- npm.io page: https://npm.io/package/substitute

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.7.1 (latest) — 2014-12-24
- 0.7.0 — 2014-12-24
- 0.6.2 — 2014-12-23
- 0.6.1 — 2014-12-23
- 0.5.1 — 2014-01-10
- 0.5.0 — 2014-01-10
- 0.3.3 — 2013-09-11
- 0.3.2 — 2013-09-11
- 0.3.1 — 2013-09-10
- 0.3.0 — 2013-08-23
- 0.2.3 — 2013-08-21
- 0.2.2 — 2013-08-21
- 0.2.0 — 2013-07-09
- 0.1.0 — 2013-07-02

## README

# Substitute

A proxy image server. This is a rewrite version of [camo](https://github.com/atmos/camo).


[![Build Status](https://travis-ci.org/lepture/substitute.png?branch=master)](https://travis-ci.org/lepture/substitute)
[![Coverage Status](https://coveralls.io/repos/lepture/substitute/badge.png?branch=master)](https://coveralls.io/r/lepture/substitute)


## 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)](http://component.io):

    $ component install lepture/substitute

And generate new src with:

```js
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](http://localhost:8000/moc.dlrowsmuabe.aidem/d42a08bfa19e5b526b0d2d53eb3b106c/picture/Mincemeat/Pimp.jpg).

Test it automatically with mocha:

```
$ make test
```

You can also test the client part with:

```
$ make test-client
```


## API


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

substitute.defaults({
    maxRedirects: 5
});

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

---
_Source: https://npm.io/package/substitute · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
