Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1191)

Unified Diff: dart/sdk/lib/_internal/lib/string_helper.dart

Issue 11973018: Improve decoding of JS TypeError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/sdk/lib/_internal/lib/js_helper.dart ('k') | dart/tests/compiler/dart2js_native/dart2js_native.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/lib/string_helper.dart
diff --git a/dart/sdk/lib/_internal/lib/string_helper.dart b/dart/sdk/lib/_internal/lib/string_helper.dart
index 1c430c8574332582ce843571bddc029872736bc5..ba03364e705547ea51c1b5a9b68cfebc8ea7e850 100644
--- a/dart/sdk/lib/_internal/lib/string_helper.dart
+++ b/dart/sdk/lib/_internal/lib/string_helper.dart
@@ -77,6 +77,8 @@ stringReplaceJS(receiver, replacer, to) {
return JS('String', r'#.replace(#, #)', receiver, replacer, to);
}
+const String ESCAPE_REGEXP = r'[[\]{}()*+?.\\^$|]';
+
stringReplaceAllUnchecked(receiver, from, to) {
checkString(to);
if (from is String) {
@@ -94,7 +96,7 @@ stringReplaceAllUnchecked(receiver, from, to) {
return result.toString();
}
} else {
- var quoter = JS('', "new RegExp(#, 'g')", r'[[\]{}()*+?.\\^$|]');
+ var quoter = JS('', "new RegExp(#, 'g')", ESCAPE_REGEXP);
var quoted = JS('String', r'#.replace(#, "\\$&")', from, quoter);
var replacer = JS('', "new RegExp(#, 'g')", quoted);
return stringReplaceJS(receiver, replacer, to);
« no previous file with comments | « dart/sdk/lib/_internal/lib/js_helper.dart ('k') | dart/tests/compiler/dart2js_native/dart2js_native.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698