Skip to content

Commit 4e944f4

Browse files
committed
Bugfixed with similar_text (thanks Chris McMacken!); minor coding standard changes
1 parent bf5f55a commit 4e944f4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

functions/strings/similar_text.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
function similar_text (first, second) {
22
// http://kevin.vanzonneveld.net
33
// + original by: Rafał Kukawski (http://blog.kukawski.pl)
4+
// + bugfixed by: Chris McMacken
45
// * example 1: similar_text('Hello World!', 'Hello phpjs!');
56
// * returns 1: 7
67
// * example 2: similar_text('Hello World!', null);
78
// * returns 2: 0
89

9-
if (first === null || second === null || typeof first === "undefined" || typeof second === "undefined") {
10+
if (first === null || second === null || typeof first === 'undefined' || typeof second === 'undefined') {
1011
return 0;
1112
}
1213

@@ -33,14 +34,13 @@ function similar_text (first, second) {
3334

3435
if (sum) {
3536
if (pos1 && pos2) {
36-
sum += similar_text(first.substr(0, pos2), second.substr(0, pos2));
37+
sum += this.similar_text(first.substr(0, pos2), second.substr(0, pos2));
3738
}
3839

3940
if ((pos1 + max < firstLength) && (pos2 + max < secondLength)) {
40-
sum += similar_text(first.substr(pos1 + max, firstLength - pos1 - max), second.substr(pos2 + max, secondLength - pos2 - max));
41+
sum += this.similar_text(first.substr(pos1 + max, firstLength - pos1 - max), second.substr(pos2 + max, secondLength - pos2 - max));
4142
}
4243
}
4344

4445
return sum;
4546
}
46-

0 commit comments

Comments
 (0)