Repository: tapestry-5 Updated Branches: refs/heads/master 875ca1c0b -> b7ac7bb5a
TAP5-2370: utils.startsWith should check for the first occurrence of the pattern in the string, not the last one Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/b7ac7bb5 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/b7ac7bb5 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/b7ac7bb5 Branch: refs/heads/master Commit: b7ac7bb5acdd4f77a6916f6ddfe83f672b3c3da0 Parents: 875ca1c Author: Jochen Kemnade <jochen.kemn...@eddyson.de> Authored: Mon Aug 18 13:01:58 2014 +0200 Committer: Jochen Kemnade <jochen.kemn...@eddyson.de> Committed: Mon Aug 18 13:01:58 2014 +0200 ---------------------------------------------------------------------- .../coffeescript/META-INF/modules/t5/core/utils.coffee | 2 +- .../tapestry5/integration/app1/pages/test-utils.coffee | 10 ++++++++++ .../tapestry5/integration/app1/pages/JavaScriptTests.java | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b7ac7bb5/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee index 39af431..5829ea0 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/utils.coffee @@ -41,7 +41,7 @@ define ["underscore"], trim: trim extendURL: extendURL - startsWith: (string, pattern) -> (string.lastIndexOf pattern) is 0 + startsWith: (string, pattern) -> (string.indexOf pattern) is 0 # Trims leading and trailing whitespace from a string. Delegates to String.prototype.trim if present. # Determines if the input is a blank string, or null, or an empty array. isBlank: (input) -> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b7ac7bb5/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-utils.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-utils.coffee b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-utils.coffee new file mode 100644 index 0000000..d1628b9 --- /dev/null +++ b/tapestry-core/src/test/coffeescript/org/apache/tapestry5/integration/app1/pages/test-utils.coffee @@ -0,0 +1,10 @@ +require ["t5/core/utils"], (utils) -> + + module "t5/core/utils" + + test "startsWith, positive case", -> + ok utils.startsWith 'foobar', 'foo' + ok utils.startsWith 'foobarfoo', 'foo' # TAP5-2370 + + test "startsWith, negative case", -> + equal (utils.startsWith 'barfoo', 'foo'), false http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/b7ac7bb5/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.java index 88127f7..14ea4a6 100644 --- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.java +++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.java @@ -9,6 +9,7 @@ import org.apache.tapestry5.annotations.Import; "test-dom.js", "test-messages.js", "test-validation.js", + "test-utils.js", // This must come last: "qunit-driver.js"},