@@ -208,6 +208,13 @@ impl<'i> Input<'i> {
208
208
}
209
209
}
210
210
211
+ pub fn trim_tab_and_newlines ( original_input : & ' i str ) -> Self {
212
+ let input = original_input. trim_matches ( ascii_tab_or_new_line) ;
213
+ Input {
214
+ chars : input. chars ( ) ,
215
+ }
216
+ }
217
+
211
218
pub fn with_log ( original_input : & ' i str , vfn : Option < & dyn Fn ( SyntaxViolation ) > ) -> Self {
212
219
let input = original_input. trim_matches ( c0_control_or_space) ;
213
220
if let Some ( vfn) = vfn {
@@ -290,6 +297,17 @@ impl Pattern for char {
290
297
}
291
298
}
292
299
300
+ impl Pattern for String {
301
+ fn split_prefix < ' i > ( self , input : & mut Input < ' i > ) -> bool {
302
+ for c in self . chars ( ) {
303
+ if input. next ( ) != Some ( c) {
304
+ return false ;
305
+ }
306
+ }
307
+ true
308
+ }
309
+ }
310
+
293
311
impl < ' a > Pattern for & ' a str {
294
312
fn split_prefix < ' i > ( self , input : & mut Input < ' i > ) -> bool {
295
313
for c in self . chars ( ) {
@@ -447,7 +465,7 @@ impl<'a> Parser<'a> {
447
465
. collect :: < String > ( )
448
466
!= "//"
449
467
} ) ;
450
- if let Some ( after_prefix) = input. split_prefix ( "//" ) {
468
+ if let Some ( after_prefix) = input. split_prefix ( "/" . repeat ( slashes_count as usize ) ) {
451
469
return self . after_double_slash ( after_prefix, scheme_type, scheme_end) ;
452
470
} else {
453
471
self . after_double_slash ( remaining, scheme_type, scheme_end)
@@ -1535,7 +1553,7 @@ fn c0_control_or_space(ch: char) -> bool {
1535
1553
1536
1554
/// https://infra.spec.whatwg.org/#ascii-tab-or-newline
1537
1555
#[ inline]
1538
- fn ascii_tab_or_new_line ( ch : char ) -> bool {
1556
+ pub fn ascii_tab_or_new_line ( ch : char ) -> bool {
1539
1557
matches ! ( ch, '\t' | '\r' | '\n' )
1540
1558
}
1541
1559
0 commit comments