camo-url
v0.2.0
Published
Create a image url by proxy that is camo.
Downloads
37
Readme
camo-url
Create a image url by proxy that is camo.
Getting started
$ npm install camo-url --save
Examples
It's very easy to use.
var camoUrl = require('camo-url')({
host: 'https://camo.yourdomain.com',
key: 'your_camo_key'
});
console.log(camoUrl('http://www.example.com/example.jpg'));
// => https://camo.yourdomain.com/c8b84571f98f34c41f7b4810a605e06d872eecd0?url=http%3A%2F%2Fwww.example.com%2Fexample.jpg
References
require('camo-url')(options)
Initialize this package.
- options ... Type:
object
... information of your camo server (optional)- host: host name (optional)
- Type:
string
- Default:
'http://localhost:8081'
- Type:
- key: camo key (optional)
- Type:
string
- Default:
'0x24FEEDFACEDEADBEEFCAFE'
- Type:
- type: proxied url type (optional)
- Type:
'query'
or'path'
- Default:
'query'
- Type:
- host: host name (optional)
camoUrl(imageUrl)
Generate a proxied image URL.
- imageUrl: an absolute URL of an image
- Type:
string
- Type:
- returns: proxied URL
- Type:
string
- Type:
camoUrl.digest(imageUrl)
Get digest of an image URL.
- imageUrl: an absolute URL of an image
- Type:
string
- Type:
- returns: digest of the URL
- Type:
string
- Type:
FAQ
Q. How do I create a GitHub style camo's URL?
A. Please try type: 'path'
option.
var camoUrl = require('camo-url')({
host: 'https://camo.yourdomain.com',
key: 'your_camo_key',
type: 'path'
});
console.log(camoUrl('http://www.example.com/example.jpg'));
// => https://camo.yourdomain.com/c8b84571f98f34c41f7b4810a605e06d872eecd0/687474703a2f2f7777772e6578616d706c652e636f6d2f6578616d706c652e6a7067
License
MIT © Pine Mizune