@@ -27,7 +27,7 @@ super::function_definition_macro::sqlpage_functions! {
27
27
hash_password( password: Option <String >) ;
28
28
header( ( & RequestInfo ) , name: Cow <str >) ;
29
29
30
- link( file: Cow <str >, parameters: Cow <str >) ;
30
+ link( file: Cow <str >, parameters: Option < Cow <str >> , hash : Option < Cow < str > >) ;
31
31
32
32
path( ( & RequestInfo ) ) ;
33
33
persist_uploaded_file( ( & RequestInfo ) , field_name: Cow <str >, folder: Option <Cow <str >>, allowed_extensions: Option <Cow <str >>) ;
@@ -197,13 +197,21 @@ async fn header<'a>(request: &'a RequestInfo, name: Cow<'a, str>) -> Option<Cow<
197
197
/// Builds a URL from a file name and a JSON object conatining URL parameters.
198
198
/// For instance, if the file is "index.sql" and the parameters are {"x": "hello world"},
199
199
/// the result will be "index.sql?x=hello%20world".
200
- async fn link < ' a > ( file : Cow < ' a , str > , parameters : Option < Cow < ' a , str > > ) -> anyhow:: Result < String > {
200
+ async fn link < ' a > (
201
+ file : Cow < ' a , str > ,
202
+ parameters : Option < Cow < ' a , str > > ,
203
+ hash : Option < Cow < ' a , str > > ,
204
+ ) -> anyhow:: Result < String > {
201
205
let mut url = file. into_owned ( ) ;
202
206
if let Some ( parameters) = parameters {
203
207
url. push ( '?' ) ;
204
208
let encoded = serde_json:: from_str :: < URLParameters > ( & parameters) ?;
205
209
url. push_str ( encoded. get ( ) ) ;
206
210
}
211
+ if let Some ( hash) = hash {
212
+ url. push ( '#' ) ;
213
+ url. push_str ( & hash) ;
214
+ }
207
215
Ok ( url)
208
216
}
209
217
0 commit comments