Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
Merge pull request #11 from matthewjackowski/master
Browse files Browse the repository at this point in the history
Trimming whitespace on the key
  • Loading branch information
laktek committed Jun 29, 2016
2 parents c87f2d9 + 6d02666 commit 1c326ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion extract_values.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
matches = matches.splice(1);
var output = {};
for (var i=0; i < tokens.length; i++) {
output[tokens[i].replace( new RegExp( delimiters[0] + "|" + delimiters[1], "g"), "")] = matches[i];
output[tokens[i].replace( new RegExp( delimiters[0] + "|" + delimiters[1], "g"), "").trim()] = matches[i];
}

return output;
Expand Down
9 changes: 7 additions & 2 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ var cases = [

[["same thing", "same thing"], {}],

[["/app/les", "/app"], null]
];
[["/app/les", "/app"], null],

[[
"<h1 class=\"p-title\">This is a title.</h1><data class=\"p-name\" value=\"This is a name\"></data>",
"<h1 class=\"p-title\"><%= title %></h1><data class=\"p-name\" value=\"<%= name %>\"></data>",
{ delimiters: ["<%=","%>"]}],{ title: 'This is a title.', name:'This is a name'}
]];

for (var i = 0; i < cases.length; i++) {
assert.deepEqual(extract_values.apply(this, cases[i][0]), cases[i][1]);
Expand Down

0 comments on commit 1c326ae

Please sign in to comment.