summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-04-16 11:32:30 +0200
committerGitHub <noreply@github.com>2018-04-16 11:32:30 +0200
commitdb8bcfc5f63518669ff608634042a5f454cda5a8 (patch)
treeafbdca7cbf7083270ce62fae4543c228bf098ca3
parent85d4d9c592045f01159a97a34ae533bb97569ce8 (diff)
parent6cb40cf0c4df35e5f895188784813587a7b9861b (diff)
downloadnextcloud-server-db8bcfc5f63518669ff608634042a5f454cda5a8.tar.gz
nextcloud-server-db8bcfc5f63518669ff608634042a5f454cda5a8.zip
Merge pull request #9172 from nextcloud/karma-avatar-tests-fix
Fix js tests with placeholder
-rw-r--r--core/js/placeholder.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/js/placeholder.js b/core/js/placeholder.js
index a73881344e3..a0dfe8491d4 100644
--- a/core/js/placeholder.js
+++ b/core/js/placeholder.js
@@ -112,7 +112,7 @@
// Convert a string to an integer evenly
function hashToInt(hash, maximum) {
- var final = 0;
+ var finalInt = 0;
var result = Array();
// Splitting evenly the string
@@ -121,13 +121,13 @@
result.push(parseInt(hash.charAt(i), 16) % 16);
}
// Adds up all results
- for (var i in result) {
- final += result[i];
+ for (var j in result) {
+ finalInt += result[j];
}
// chars in md5 goes up to f, hex:16
- return parseInt(final % maximum);
+ // make sure we're always using int in our operation
+ return parseInt(parseInt(finalInt) % maximum);
}
-
return finalPalette[hashToInt(hash, steps * 3 )];
};