@@ -6,7 +6,7 @@ use url::Url;
6
6
7
7
use crate :: QueryEngine ;
8
8
9
- pub const HOST : & str = "generated " ;
9
+ pub const SCHEME : & str = "prim " ;
10
10
pub const PRIM : & str = include_str ! ( "prim/Prim.purs" ) ;
11
11
pub const PRIM_BOOLEAN : & str = include_str ! ( "prim/Prim.Boolean.purs" ) ;
12
12
pub const PRIM_COERCE : & str = include_str ! ( "prim/Prim.Coerce.purs" ) ;
@@ -29,7 +29,7 @@ pub fn configure(engine: &mut QueryEngine, files: &mut Files) {
29
29
( "Prim.Symbol" , PRIM_SYMBOL ) ,
30
30
( "Prim.TypeError" , PRIM_TYPE_ERROR ) ,
31
31
] {
32
- let path = format ! ( "file ://{HOST} /{name}.purs" ) ;
32
+ let path = format ! ( "{SCHEME} ://localhost /{name}.purs" ) ;
33
33
let id = files. insert ( path, content) ;
34
34
35
35
engine. set_content ( id, content) ;
@@ -44,15 +44,12 @@ pub static TEMPORARY_DIRECTORY: LazyLock<TempDir> = LazyLock::new(|| {
44
44
. expect ( "invariant violated: failed to create TEMPORARY_DIRECTORY" )
45
45
} ) ;
46
46
47
- pub fn handle_generated ( mut uri : Url , content : & str ) -> Option < Url > {
48
- if uri. host_str ( ) != Some ( HOST ) {
47
+ pub fn handle_generated ( uri : Url , content : & str ) -> Option < Url > {
48
+ if uri. scheme ( ) != SCHEME {
49
49
return Some ( uri) ;
50
50
}
51
51
52
- uri. set_host ( Some ( "localhost" ) ) . ok ( ) ?;
53
- let original = uri. to_file_path ( ) . ok ( ) ?;
54
-
55
- let file = original. components ( ) . next_back ( ) ?;
52
+ let file = uri. path_segments ( ) ?. next_back ( ) ?;
56
53
let path = TEMPORARY_DIRECTORY . path ( ) . join ( file) ;
57
54
58
55
let mut file = File :: create ( & path) . ok ( ) ?;
0 commit comments