@@ -75,49 +75,64 @@ private static UriPattern ParsePattern(ReadOnlySpan<char> patternSpan)
7575 Query = ParseQuery ( queryPattern )
7676 } ;
7777
78- static Value < string > ParseScheme ( ReadOnlySpan < char > scheme ) => scheme switch
78+ static Value < string > ParseScheme ( ReadOnlySpan < char > scheme )
7979 {
80- [ ] => Value . Any ( ) ,
81- [ '*' ] => Value . Any ( ) ,
82- _ when scheme . IndexOf ( '*' ) != - 1 => Value . Pattern ( scheme . ToString ( ) ) ,
83- _ => Value . Exact ( scheme . ToString ( ) )
84- } ;
80+ return scheme switch
81+ {
82+ [ ] => Value . Any ( ) ,
83+ [ '*' ] => Value . Any ( ) ,
84+ _ when scheme . IndexOf ( '*' ) != - 1 => Value . Pattern ( scheme . ToString ( ) ) ,
85+ _ => Value . Exact ( scheme . ToString ( ) )
86+ } ;
87+ }
8588
86- static Value < string > ParseHost ( ReadOnlySpan < char > host ) => host switch
89+ static Value < string > ParseHost ( ReadOnlySpan < char > host )
8790 {
88- [ ] => Value . Any ( ) ,
89- [ '*' ] => Value . Any ( ) ,
90- _ when host . IndexOf ( '*' ) != - 1 => Value . Pattern ( host . ToString ( ) ) ,
91- _ => Value . Exact ( host . ToString ( ) )
92- } ;
91+ return host switch
92+ {
93+ [ ] => Value . Any ( ) ,
94+ [ '*' ] => Value . Any ( ) ,
95+ _ when host . IndexOf ( '*' ) != - 1 => Value . Pattern ( host . ToString ( ) ) ,
96+ _ => Value . Exact ( host . ToString ( ) )
97+ } ;
98+ }
9399
94- static Value < string > ParsePort ( ReadOnlySpan < char > port ) => port switch
100+ static Value < string > ParsePort ( ReadOnlySpan < char > port )
95101 {
96- [ ] => Value . Any ( ) ,
97- [ ':' ] => throw new UriPatternParserException ( "Invalid port" ) ,
98- [ ':' , '*' ] => Value . Any ( ) ,
99- [ ':' , .. var rest ] when rest. IndexOf ( '*' ) != - 1 => Value. Pattern ( rest . ToString ( ) ) ,
100- [ ':' , .. var rest] => Value . Exact ( rest . ToString ( ) ) ,
101- _ => throw new UnreachableException ( )
102- } ;
102+ return port switch
103+ {
104+ [ ] => Value . Any ( ) ,
105+ [ ':' ] => throw new UriPatternParserException ( "Invalid port" ) ,
106+ [ ':' , '*' ] => Value . Any ( ) ,
107+ [ ':' , .. var rest ] when rest. IndexOf ( '*' ) != - 1 => Value. Pattern ( rest . ToString ( ) ) ,
108+ [ ':' , .. var rest] => Value . Exact ( rest . ToString ( ) ) ,
109+ _ => throw new UnreachableException ( )
110+ } ;
111+ }
103112
104- static Value < string > ParsePath ( ReadOnlySpan < char > path ) => path switch
113+ static Value < string > ParsePath ( ReadOnlySpan < char > path )
105114 {
106- [ ] => Value . Any ( ) ,
107- [ '/' , '*' ] => Value . Any ( ) ,
108- [ '/' , .. var rest ] when rest. IndexOf ( '*' ) != - 1 => Value. Pattern ( path . ToString ( ) ) ,
109- [ '/' , ..] => Value. Exact ( path . ToString ( ) ) ,
110- _ => throw new UnreachableException ( )
111- } ;
115+ return path switch
116+ {
117+ [ ] => Value . Any ( ) ,
118+ [ '/' , '*' ] => Value. Any ( ) ,
119+ [ '/' , .. var rest ] when rest. IndexOf ( '*' ) != - 1 => Value. Pattern ( path . ToString ( ) ) ,
120+ [ '/' , ..] => Value. Exact ( path . ToString ( ) ) ,
121+ _ => throw new UnreachableException ( )
122+ } ;
123+ }
112124
113- static Value < string > ParseQuery ( ReadOnlySpan < char > query ) => query switch
125+ static Value < string > ParseQuery ( ReadOnlySpan < char > query )
114126 {
115- [ ] => Value . Any ( ) ,
116- [ '?' ] => Value . Any ( ) ,
117- [ '?' , '*' ] => Value . Any ( ) ,
118- [ '?' , .. var rest ] when rest. IndexOf ( '*' ) != - 1 => Value. Pattern ( rest . ToString ( ) ) ,
119- [ '?' , .. var rest] => Value . Exact ( rest . ToString ( ) ) ,
120- _ => throw new UnreachableException ( )
121- } ;
127+ return query switch
128+ {
129+ [ ] => Value . Any ( ) ,
130+ [ '?' ] => Value. Any ( ) ,
131+ [ '?' , '*' ] => Value. Any ( ) ,
132+ [ '?' , .. var rest ] when rest. IndexOf ( '*' ) != - 1 => Value. Pattern ( rest . ToString ( ) ) ,
133+ [ '?' , .. var rest] => Value . Exact ( rest . ToString ( ) ) ,
134+ _ => throw new UnreachableException ( )
135+ } ;
136+ }
122137 }
123138}
0 commit comments