Urlinate
Adds data to a URL
var newUrl = urlinate(url, data)
Adds data to a URL. As syntax sugar for recursion, if the data provided contains an object with a key === '$'
, the value at that key will be considered an array of arguments to pass to urlinate to obtain a string which will replace said object.
- url (string) - Anything you can pass to Node's url.parse
- data (object) - The data to add to the URL
- returns (string) newUrl - the original url but with specified data encoded in the
d
query parameter
var urlinator = // cachinate.io?asset=imaginate.io%3Finput%3Dimgs.io%252Fa.jpg
Why?
This makes it easy to create an ecosystem of chainable HTTP GET APIs. This is useful if, for example, a browser is launching a request for you (from an image tag or css instruction) but you still want to use your API.