Skip to content

Commit

Permalink
Use the "g" and "m" flags on the regular expression used to remove
Browse files Browse the repository at this point in the history
escape characters. Added tests to ensure they are all removed.

Fixes #1.
  • Loading branch information
abstrctn committed Mar 6, 2015
1 parent 1975bfd commit 74f4793
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion archieml.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function load(input) {
// If we're appending to a multi-line string, escape special punctuation
// by using a backslash at the beginning of any line.
// Note we do not do this processing for the first line of any value.
value = value.replace(new RegExp('^(\\s*)\\\\'), "$1");
value = value.replace(new RegExp('^(\\s*)\\\\', 'gm'), "$1");
}

return value;
Expand Down
2 changes: 2 additions & 0 deletions test/archieml.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
equal(load('key:value\n\\\\:end\n:end').key, 'value\n\\:end', 'allows escaping initial backslash at the beginning of lines');
equal(load('key:value\n\\\\\\:end\n:end').key, 'value\n\\\\:end', 'escapes only one initial backslash');

equal(load('key:value\n\\:end\n\\:ignore\n\\:endskip\n\\:skip\n:end').key, 'value\n:end\n:ignore\n:endskip\n:skip', 'allows escaping multiple lines in a value');

equal(load('key:value\nLorem key2\\:value\n:end').key, 'value\nLorem key2\\:value', "doesn't escape colons after beginning of lines");
});

Expand Down

0 comments on commit 74f4793

Please sign in to comment.