File tree 2 files changed +13
-6
lines changed
2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -14,5 +14,6 @@ web-sys = { version = "0.3.69", features = [
14
14
" HtmlElement" ,
15
15
" HtmlInputElement" ,
16
16
" CssStyleDeclaration" ,
17
+ " Location"
17
18
] }
18
19
js-sys = " 0.3"
Original file line number Diff line number Diff line change 1
1
use wasm_bindgen:: prelude:: * ;
2
2
use web_sys:: js_sys:: Function ;
3
3
use web_sys:: { Document , Element , HtmlElement , HtmlInputElement } ;
4
-
5
- // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
6
- // allocator.
7
- #[ cfg( feature = "wee_alloc" ) ]
8
- #[ global_allocator]
9
- static ALLOC : wee_alloc:: WeeAlloc = wee_alloc:: WeeAlloc :: INIT ;
4
+ use wasm_bindgen:: JsCast ;
10
5
11
6
#[ wasm_bindgen]
12
7
pub fn run_stack ( src : & str ) -> Result {
@@ -1104,6 +1099,17 @@ impl Executor {
1104
1099
. expect ( "チノちゃん「うるさいですね...」" ) ;
1105
1100
}
1106
1101
1102
+ "get-url" => {
1103
+ // Access the window object
1104
+ let window = web_sys:: window ( ) . expect ( "no global `window` exists" ) ;
1105
+
1106
+ // Access the current URL
1107
+ let location = window. location ( ) ;
1108
+
1109
+ // Get the full URL as a string
1110
+ self . stack . push ( Type :: String ( location. href ( ) . expect ( "should have href" ) ) )
1111
+ }
1112
+
1107
1113
// If it is not recognized as a command, use it as a string.
1108
1114
_ => self . stack . push ( Type :: String ( command) ) ,
1109
1115
}
You can’t perform that action at this time.
0 commit comments