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

Unified Diff: pkg/string_scanner/lib/string_scanner.dart

Issue 222613006: Fix the StringScanner tests under dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/string_scanner/lib/string_scanner.dart
diff --git a/pkg/string_scanner/lib/string_scanner.dart b/pkg/string_scanner/lib/string_scanner.dart
index 31ccd62664f82a3d9f3a3193917db70c13e0254f..3e3913b50169ba5796102c6314aba658341457b8 100644
--- a/pkg/string_scanner/lib/string_scanner.dart
+++ b/pkg/string_scanner/lib/string_scanner.dart
@@ -7,6 +7,11 @@ library string_scanner;
import 'dart:math' as math;
+/// When compiled to JS, forward slashes are always escaped in [RegExp.pattern].
+///
+/// See issue 17998.
+final _slashAutoEscape = new RegExp("/").pattern == "\\/";
+
// TODO(nweiz): Add some integration between this and source maps.
/// A class that scans through a string using [Pattern]s.
class StringScanner {
@@ -65,7 +70,9 @@ class StringScanner {
if (name == null) {
if (pattern is RegExp) {
- name = "/${pattern.pattern.replaceAll("/", "\\/")}/";
+ var source = pattern.pattern;
+ if (!_slashAutoEscape) source = source.replaceAll("/", "\\/");
+ name = "/$source/";
} else {
name = pattern.toString()
.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698