@@ -190,6 +190,13 @@ impl<'i> Input<'i> {
190190 }
191191 }
192192
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+
193200 pub fn with_log ( original_input : & ' i str , vfn : Option < & dyn Fn ( SyntaxViolation ) > ) -> Self {
194201 let input = original_input. trim_matches ( c0_control_or_space) ;
195202 if let Some ( vfn) = vfn {
@@ -272,6 +279,17 @@ impl Pattern for char {
272279 }
273280}
274281
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+
275293impl < ' a > Pattern for & ' a str {
276294 fn split_prefix < ' i > ( self , input : & mut Input < ' i > ) -> bool {
277295 for c in self . chars ( ) {
@@ -429,7 +447,7 @@ impl<'a> Parser<'a> {
429447 . collect :: < String > ( )
430448 != "//"
431449 } ) ;
432- if let Some ( after_prefix) = input. split_prefix ( "//" ) {
450+ if let Some ( after_prefix) = input. split_prefix ( "/" . repeat ( slashes_count as usize ) ) {
433451 return self . after_double_slash ( after_prefix, scheme_type, scheme_end) ;
434452 } else {
435453 self . after_double_slash ( remaining, scheme_type, scheme_end)
@@ -1517,7 +1535,7 @@ fn c0_control_or_space(ch: char) -> bool {
15171535
15181536/// https://infra.spec.whatwg.org/#ascii-tab-or-newline
15191537#[ inline]
1520- fn ascii_tab_or_new_line ( ch : char ) -> bool {
1538+ pub fn ascii_tab_or_new_line ( ch : char ) -> bool {
15211539 matches ! ( ch, '\t' | '\r' | '\n' )
15221540}
15231541
0 commit comments