-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c2fc6cd
Showing
9 changed files
with
170 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
coverage | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"maxerr": 100, // Maximum errors before stopping. | ||
"maxlen": 80, // Maximum line length. | ||
"quotmark": "single", // Consistent quotation mark usage. | ||
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.). | ||
"curly": true, // Require {} for every new block or scope. | ||
"eqeqeq": true, // Require triple equals i.e. `===`. | ||
"forin": false, // Tolerate `for in` loops without `hasOwnPrototype`. | ||
"immed": true, // Require immediate invocations to be wrapped in parens. E.g. `(function(){})();`. | ||
"latedef": false, // Prohibit variable use before definition. | ||
"newcap": true, // Require capitalization of all constructor functions. E.g. `new F()`. | ||
"noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`. | ||
"noempty": true, // Prohibit use of empty blocks. | ||
"nonew": true, // Prohibit use of constructors for side-effects. | ||
"undef": true, // Require all non-global variables be declared before they are used. | ||
"unused": true, // Warn when creating a variable but never using it. | ||
"plusplus": false, // Prohibit use of `++` & `--`. | ||
"regexp": false, // Prohibit `.` and `[^...]` in regular expressions. | ||
"strict": false, // Require `use strict` pragma in every file. | ||
"trailing": true, // Prohibit trailing whitespaces. | ||
"boss": true, // Tolerate assignments inside if, for and while. Usually conditions and loops are for comparison, not assignments. | ||
"multistr": false, // Prohibit the use of multi-line strings. | ||
"eqnull": true, // Tolerate use of `== null`. | ||
"expr": true, // Tolerate `ExpressionStatement` as Programs. | ||
"node": true, // Support globals used in a node environment. | ||
"browser": true, // Support globals used in a browser environment. | ||
"globals": { | ||
"popsicle": true, | ||
"describe": true, | ||
"it": true, | ||
"define": true, | ||
"expect": true, | ||
"beforeEach": true, | ||
"afterEach": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
language: node_js | ||
|
||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: change | ||
|
||
node_js: | ||
- "0.10" | ||
- "0.11" | ||
|
||
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Popsicle Prefix | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![Build status][travis-image]][travis-url] | ||
[![Test coverage][coveralls-image]][coveralls-url] | ||
|
||
Prefix all Popsicle HTTP requests. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install popsicle-prefix --save | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
var request = require('popsicle'); | ||
var prefix = require('popsicle-prefix'); | ||
|
||
request('/users.json') | ||
.use(prefix('http://example.com')); | ||
``` | ||
|
||
## License | ||
|
||
MIT | ||
|
||
[npm-image]: https://img.shields.io/npm/v/popsicle-prefix.svg?style=flat | ||
[npm-url]: https://npmjs.org/package/popsicle-prefix | ||
[travis-image]: https://img.shields.io/travis/blakeembrey/popsicle-prefix.svg?style=flat | ||
[travis-url]: https://travis-ci.org/blakeembrey/popsicle-prefix | ||
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/popsicle-prefix.svg?style=flat | ||
[coveralls-url]: https://coveralls.io/r/blakeembrey/popsicle-prefix?branch=master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "popsicle-prefix", | ||
"version": "0.0.0", | ||
"description": "Prefix all Popsicle HTTP requests", | ||
"main": "popsicle-prefix.js", | ||
"scripts": { | ||
"test": "istanbul cover _mocha -- -R spec" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/blakeembrey/popsicle-prefix.git" | ||
}, | ||
"keywords": [ | ||
"popsicle", | ||
"plugin", | ||
"prefix" | ||
], | ||
"author": { | ||
"name": "Blake Embrey", | ||
"email": "hello@blakeembrey.com", | ||
"url": "http://blakeembrey.me" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/blakeembrey/popsicle-prefix/issues" | ||
}, | ||
"homepage": "https://github.com/blakeembrey/popsicle-prefix", | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"istanbul": "^0.3.5", | ||
"mocha": "^2.0.1", | ||
"popsicle": "^0.1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
function prefixPopsicle (prefix) { | ||
prefix = prefix.replace(/\/$/, ''); | ||
|
||
return function (request) { | ||
request.url = prefix + '/' + request.url.replace(/^\//, ''); | ||
}; | ||
} | ||
|
||
module.exports = prefixPopsicle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var popsicle = require('popsicle'); | ||
var expect = require('chai').expect; | ||
var prefix = require('./'); | ||
|
||
describe('popsicle prefix', function () { | ||
it('should prefix all urls', function () { | ||
var req = popsicle('http://example.com') | ||
.use(prefix('/proxy')); | ||
|
||
expect(req.url).to.equal('/proxy/http://example.com'); | ||
}); | ||
}); |