rewrite the rewriter

This commit is contained in:
velzie 2024-07-18 20:26:13 -04:00
parent 73c1c8a5c8
commit 6a5ecc4efc
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
6 changed files with 62 additions and 128 deletions

View file

@ -1,6 +1,9 @@
pub mod rewrite;
use std::str::{from_utf8, FromStr};
use std::{
panic,
str::{from_utf8, FromStr},
};
use js_sys::Uint8Array;
use rewrite::rewrite;
@ -13,6 +16,11 @@ extern "C" {
fn log(s: &str);
}
#[wasm_bindgen]
pub fn init() {
panic::set_hook(Box::new(console_error_panic_hook::hook));
}
#[wasm_bindgen]
pub fn rewrite_js(js: &str, url: &str) -> Vec<u8> {
rewrite(js, Url::from_str(url).unwrap())