@@ -124,17 +124,18 @@ pub fn render(
124
124
query_and_params : & str ,
125
125
split_odb : bool ,
126
126
) -> JoshResult < Option < ( String , std:: collections:: BTreeMap < String , String > ) > > {
127
- let mut parameters = query_and_params. split ( '&' ) ;
128
- let query = parameters
129
- . next ( )
130
- . ok_or_else ( || josh_error ( & format ! ( "invalid query {:?}" , query_and_params) ) ) ?;
131
- let mut split = query. splitn ( 2 , '=' ) ;
132
- let cmd = split
133
- . next ( )
134
- . ok_or_else ( || josh_error ( & format ! ( "invalid query {:?}" , query_and_params) ) ) ?;
135
- let path = split
136
- . next ( )
137
- . ok_or_else ( || josh_error ( & format ! ( "invalid query {:?}" , query_and_params) ) ) ?;
127
+ let params = form_urlencoded:: parse ( & query_and_params. as_bytes ( ) )
128
+ . map ( |( x, y) | ( x. to_string ( ) , y. to_string ( ) ) )
129
+ . collect :: < std:: collections:: BTreeMap < _ , _ > > ( ) ;
130
+ let ( cmd, path) = if let Some ( path) = params. get ( "get" ) {
131
+ ( "get" , path)
132
+ } else if let Some ( path) = params. get ( "graphql" ) {
133
+ ( "graphql" , path)
134
+ } else if let Some ( path) = params. get ( "render" ) {
135
+ ( "render" , path)
136
+ } else {
137
+ return Err ( josh_error ( "no command" ) ) ;
138
+ } ;
138
139
139
140
let tree = transaction. repo ( ) . find_commit ( commit_id) ?. tree ( ) ?;
140
141
@@ -146,18 +147,6 @@ pub fn render(
146
147
}
147
148
) ;
148
149
149
- let mut params = std:: collections:: BTreeMap :: new ( ) ;
150
- for p in parameters {
151
- let mut split = p. splitn ( 2 , '=' ) ;
152
- let name = split
153
- . next ( )
154
- . ok_or_else ( || josh_error ( & format ! ( "invalid query {:?}" , query_and_params) ) ) ?;
155
- let value = split
156
- . next ( )
157
- . ok_or_else ( || josh_error ( & format ! ( "invalid query {:?}" , query_and_params) ) ) ?;
158
- params. insert ( name. to_string ( ) , value. to_string ( ) ) ;
159
- }
160
-
161
150
let template = if let Ok ( blob) = obj. peel_to_blob ( ) {
162
151
let file = std:: str:: from_utf8 ( blob. content ( ) ) ?;
163
152
if cmd == "get" {
0 commit comments