@@ -190,6 +190,13 @@ impl<'i> Input<'i> {
190
190
}
191
191
}
192
192
193
+ pub fn trim_tab_and_newlines ( original_input : & ' i str ) -> Self {
194
+ let input = original_input. trim_matches ( ascii_tab_or_new_line) ;
195
+ Input {
196
+ chars : input. chars ( ) ,
197
+ }
198
+ }
199
+
193
200
pub fn with_log ( original_input : & ' i str , vfn : Option < & dyn Fn ( SyntaxViolation ) > ) -> Self {
194
201
let input = original_input. trim_matches ( c0_control_or_space) ;
195
202
if let Some ( vfn) = vfn {
@@ -272,6 +279,17 @@ impl Pattern for char {
272
279
}
273
280
}
274
281
282
+ impl Pattern for String {
283
+ fn split_prefix < ' i > ( self , input : & mut Input < ' i > ) -> bool {
284
+ for c in self . chars ( ) {
285
+ if input. next ( ) != Some ( c) {
286
+ return false ;
287
+ }
288
+ }
289
+ true
290
+ }
291
+ }
292
+
275
293
impl < ' a > Pattern for & ' a str {
276
294
fn split_prefix < ' i > ( self , input : & mut Input < ' i > ) -> bool {
277
295
for c in self . chars ( ) {
@@ -429,7 +447,7 @@ impl<'a> Parser<'a> {
429
447
. collect :: < String > ( )
430
448
!= "//"
431
449
} ) ;
432
- if let Some ( after_prefix) = input. split_prefix ( "//" ) {
450
+ if let Some ( after_prefix) = input. split_prefix ( "/" . repeat ( slashes_count as usize ) ) {
433
451
return self . after_double_slash ( after_prefix, scheme_type, scheme_end) ;
434
452
} else {
435
453
self . after_double_slash ( remaining, scheme_type, scheme_end)
@@ -1517,7 +1535,7 @@ fn c0_control_or_space(ch: char) -> bool {
1517
1535
1518
1536
/// https://infra.spec.whatwg.org/#ascii-tab-or-newline
1519
1537
#[ inline]
1520
- fn ascii_tab_or_new_line ( ch : char ) -> bool {
1538
+ pub fn ascii_tab_or_new_line ( ch : char ) -> bool {
1521
1539
matches ! ( ch, '\t' | '\r' | '\n' )
1522
1540
}
1523
1541
0 commit comments