@@ -208,6 +208,13 @@ impl<'i> Input<'i> {
208208 }
209209 }
210210
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+
211218 pub fn with_log ( original_input : & ' i str , vfn : Option < & dyn Fn ( SyntaxViolation ) > ) -> Self {
212219 let input = original_input. trim_matches ( c0_control_or_space) ;
213220 if let Some ( vfn) = vfn {
@@ -290,6 +297,17 @@ impl Pattern for char {
290297 }
291298}
292299
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+
293311impl < ' a > Pattern for & ' a str {
294312 fn split_prefix < ' i > ( self , input : & mut Input < ' i > ) -> bool {
295313 for c in self . chars ( ) {
@@ -447,7 +465,7 @@ impl<'a> Parser<'a> {
447465 . collect :: < String > ( )
448466 != "//"
449467 } ) ;
450- if let Some ( after_prefix) = input. split_prefix ( "//" ) {
468+ if let Some ( after_prefix) = input. split_prefix ( "/" . repeat ( slashes_count as usize ) ) {
451469 return self . after_double_slash ( after_prefix, scheme_type, scheme_end) ;
452470 } else {
453471 self . after_double_slash ( remaining, scheme_type, scheme_end)
@@ -1535,7 +1553,7 @@ fn c0_control_or_space(ch: char) -> bool {
15351553
15361554/// https://infra.spec.whatwg.org/#ascii-tab-or-newline
15371555#[ inline]
1538- fn ascii_tab_or_new_line ( ch : char ) -> bool {
1556+ pub fn ascii_tab_or_new_line ( ch : char ) -> bool {
15391557 matches ! ( ch, '\t' | '\r' | '\n' )
15401558}
15411559
0 commit comments