[Pkg-javascript-commits] [node-strip-json-comments] 07/11: Imported Upstream version 2.0.1
Julien Puydt
julien.puydt at laposte.net
Sat May 14 07:12:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-strip-json-comments.
commit 9afc99d3849a17af4b3c4662a983d413926537c0
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Sat May 14 08:50:32 2016 +0200
Imported Upstream version 2.0.1
---
index.js | 2 +-
package.json | 2 +-
test.js | 14 ++++++--------
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/index.js b/index.js
index 1837ca3..4e6576e 100644
--- a/index.js
+++ b/index.js
@@ -66,5 +66,5 @@ module.exports = function (str, opts) {
}
}
- return ret + str.substr(offset);
+ return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
};
diff --git a/package.json b/package.json
index abec6d8..288ecc7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "strip-json-comments",
- "version": "2.0.0",
+ "version": "2.0.1",
"description": "Strip comments from JSON. Lets you use comments in your JSON files!",
"license": "MIT",
"repository": "sindresorhus/strip-json-comments",
diff --git a/test.js b/test.js
index de39040..971f0d4 100644
--- a/test.js
+++ b/test.js
@@ -9,7 +9,6 @@ test('replace comments with whitespace', t => {
t.is(fn('{"a"/*\n\n\ncomment\r\n*/:"b"}'), '{"a" \n\n\n \r\n :"b"}');
t.is(fn('/*!\n * comment\n */\n{"a":"b"}'), ' \n \n \n{"a":"b"}');
t.is(fn('{/*comment*/"a":"b"}'), '{ "a":"b"}');
- t.end();
});
test('remove comments', t => {
@@ -21,7 +20,6 @@ test('remove comments', t => {
t.is(fn('{"a"/*\n\n\ncomment\r\n*/:"b"}', opts), '{"a":"b"}');
t.is(fn('/*!\n * comment\n */\n{"a":"b"}', opts), '\n{"a":"b"}');
t.is(fn('{/*comment*/"a":"b"}', opts), '{"a":"b"}');
- t.end();
});
test('doesn\'t strip comments inside strings', t => {
@@ -29,35 +27,35 @@ test('doesn\'t strip comments inside strings', t => {
t.is(fn('{"a":"b/*c*/"}'), '{"a":"b/*c*/"}');
t.is(fn('{"/*a":"b"}'), '{"/*a":"b"}');
t.is(fn('{"\\"/*a":"b"}'), '{"\\"/*a":"b"}');
- t.end();
});
test('consider escaped slashes when checking for escaped string quote', t => {
t.is(fn('{"\\\\":"https://foobar.com"}'), '{"\\\\":"https://foobar.com"}');
t.is(fn('{"foo\\\"":"https://foobar.com"}'), '{"foo\\\"":"https://foobar.com"}');
- t.end();
});
test('line endings - no comments', t => {
t.is(fn('{"a":"b"\n}'), '{"a":"b"\n}');
t.is(fn('{"a":"b"\r\n}'), '{"a":"b"\r\n}');
- t.end();
});
test('line endings - single line comment', t => {
t.is(fn('{"a":"b"//c\n}'), '{"a":"b" \n}');
t.is(fn('{"a":"b"//c\r\n}'), '{"a":"b" \r\n}');
- t.end();
});
test('line endings - single line block comment', t => {
t.is(fn('{"a":"b"/*c*/\n}'), '{"a":"b" \n}');
t.is(fn('{"a":"b"/*c*/\r\n}'), '{"a":"b" \r\n}');
- t.end();
});
test('line endings - multi line block comment', t => {
t.is(fn('{"a":"b",/*c\nc2*/"x":"y"\n}'), '{"a":"b", \n "x":"y"\n}');
t.is(fn('{"a":"b",/*c\r\nc2*/"x":"y"\r\n}'), '{"a":"b", \r\n "x":"y"\r\n}');
- t.end();
+});
+
+test('line endings - works at EOF', t => {
+ const opts = {whitespace: false};
+ t.is(fn('{\r\n\t"a":"b"\r\n} //EOF'), '{\r\n\t"a":"b"\r\n} ');
+ t.is(fn('{\r\n\t"a":"b"\r\n} //EOF', opts), '{\r\n\t"a":"b"\r\n} ');
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-strip-json-comments.git
More information about the Pkg-javascript-commits
mailing list