Index: runtime/lib/string_patch.dart |
diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart |
index 80b369cb10003122b2307fe367cc762914e68254..2d40f2de1eff3fafe8d2d639562cfac914098f0d 100644 |
--- a/runtime/lib/string_patch.dart |
+++ b/runtime/lib/string_patch.dart |
@@ -129,11 +129,14 @@ class _StringBase { |
return _substringMatches(this.length - other.length, other); |
} |
- bool startsWith(Pattern pattern) { |
+ bool startsWith(Pattern pattern, [int index = 0]) { |
+ if (index < 0 || index > this.length) { |
+ throw new RangeError.range(index, 0, this.length); |
+ } |
if (pattern is String) { |
- return _substringMatches(0, pattern); |
+ return _substringMatches(index, pattern); |
} |
- return pattern.matchAsPrefix(this, 0) != null; |
+ return pattern.matchAsPrefix(this, index) != null; |
} |
int indexOf(Pattern pattern, [int start = 0]) { |