This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Showing
6 changed files
with
89 additions
and
1 deletion.
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,2 @@ | ||
node_modules | ||
.idea |
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 @@ | ||
test: | ||
./node_modules/.bin/mocha --reporter nyan | ||
.PHONY: test |
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 |
---|---|---|
@@ -1 +1,11 @@ | ||
# aws-lambda-router | ||
# aws-lambda-router | ||
|
||
A small library providing utility methods to `escape` and `unescape` HTML entities | ||
|
||
## Tests | ||
|
||
npm test | ||
|
||
## Release History | ||
|
||
* 0.0.1 Initial release |
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,29 @@ | ||
/** | ||
* Escape special characters in the given string of html. | ||
* | ||
* @param {String} html | ||
* @return {String} | ||
*/ | ||
module.exports = { | ||
escape: function(html) { | ||
return String(html) | ||
.replace(/&/g, '&') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, ''') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>'); | ||
}, | ||
|
||
/** | ||
* Unescape special characters in the given string of html. | ||
* | ||
* @param {String} html | ||
* @return {String} | ||
*/ | ||
unescape: function(html) { | ||
return String(html) | ||
.replace(/&/g, '&') | ||
.replace(/"/g, '"') | ||
.replace(/>/g, '>'); | ||
} | ||
}; |
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,28 @@ | ||
{ | ||
"name": "aws-lambda-router", | ||
"version": "0.0.1", | ||
"description": "AWS lambda router", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/WeltN24/aws-lambda-router.git" | ||
}, | ||
"keywords": [ | ||
"aws", | ||
"lambda", | ||
"any" | ||
], | ||
"author": "Christian Gohlke <[email protected]> (https://www.welt.de)", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/WeltN24/aws-lambda-router/issues" | ||
}, | ||
"homepage": "https://github.com/WeltN24/aws-lambda-router#readme", | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"mocha": "^3.1.0" | ||
} | ||
} |
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,16 @@ | ||
var should = require('chai').should(), | ||
scapegoat = require('../index'), | ||
escape = scapegoat.escape, | ||
unescape = scapegoat.unescape; | ||
|
||
describe('#escape', function() { | ||
it('converts & into &', function() { | ||
escape('&').should.equal('&'); | ||
}); | ||
}); | ||
|
||
describe('#unescape', function() { | ||
it('converts & into &', function() { | ||
unescape('&').should.equal('&'); | ||
}); | ||
}); |