Skip to content

Commit

Permalink
Add lodash test
Browse files Browse the repository at this point in the history
  • Loading branch information
anandsaw committed Aug 3, 2024
1 parent 6165ca5 commit 6baa0dc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lodash_vuln.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const _ = require('lodash');

function containsUnicodeWord(string) {
// Convert the string to an array of words using lodash's words function
const words = _.words(string);

// Check if any word has a Unicode character
return words.some(word => /[^\u0000-\u007F]+/.test(word));
}

const example1 = "Hello world!";
const example2 = "你好,世界!";

console.log(containsUnicodeWord(example1)); // false
console.log(containsUnicodeWord(example2)); // true
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"minimist": "1.2.5",
"mongodb": "^3.5.9",
"mongoose": "4.2.4"
"mongoose": "4.2.4",
"lodash": "4.17.4"
}
}

0 comments on commit 6baa0dc

Please sign in to comment.