accept owned version of bytes and string

This commit is contained in:
Toshit Chawda 2024-10-22 17:45:11 -07:00
parent 9166fed573
commit e7bef2b1c0
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
2 changed files with 9 additions and 9 deletions

View file

@ -9,7 +9,7 @@
<a href="https://www.npmjs.com/package/@mercuryworkshop/scramjet"><img src="https://img.shields.io/npm/v/@mercuryworkshop/scramjet.svg?maxAge=3600" alt="npm version" /></a>
Scramjet is an experimental inteception based web proxy that aims to be the successor to Ultraviolet. It is designed with security, developer friendlyness, and performance in mind. Scramjet strives to have a clean, organized codebase to improve maintainability. Scramjet is made to evade internet censorship and bypass arbitrary web browser restrictions.
Scramjet is an experimental interception based web proxy that aims to be the successor to Ultraviolet. It is designed with security, developer friendliness, and performance in mind. Scramjet strives to have a clean, organized codebase to improve maintainability. Scramjet is made to evade internet censorship and bypass arbitrary web browser restrictions.
## Supported Sites
@ -35,7 +35,7 @@ Some of the popular websites that Scramjet supports include:
#### Building
- Clone the repository with `git clone --recursive https://github.com/MercuryWorkshop/scramjet`
- Then, install your dependencies with `pnpm i`
- Then, install the dependencies with `pnpm i`
- After, build the rewriter with `pnpm rewriter:build`
- Finally, build Scramjet with `pnpm build`

View file

@ -138,7 +138,7 @@ fn create_rewriter_output(
#[wasm_bindgen]
pub fn rewrite_js(
js: &str,
js: String,
url: &str,
script_url: String,
scramjet: &Object,
@ -149,15 +149,15 @@ pub fn rewrite_js(
}
let before = Instant::now();
let out = rewrite(js, Url::from_str(url)?, get_config(scramjet, url)?)?;
let out = rewrite(&js, Url::from_str(url)?, get_config(scramjet, url)?)?;
let after = Instant::now();
create_rewriter_output(out, script_url, js.to_string(), after - before)
create_rewriter_output(out, script_url, js, after - before)
}
#[wasm_bindgen]
pub fn rewrite_js_from_arraybuffer(
js: &[u8],
js: Vec<u8>,
url: &str,
script_url: String,
scramjet: &Object,
@ -168,11 +168,11 @@ pub fn rewrite_js_from_arraybuffer(
}
// we know that this is a valid utf-8 string
let js = unsafe { std::str::from_utf8_unchecked(js) };
let js = unsafe { String::from_utf8_unchecked(js) };
let before = Instant::now();
let out = rewrite(js, Url::from_str(url)?, get_config(scramjet, url)?)?;
let out = rewrite(&js, Url::from_str(url)?, get_config(scramjet, url)?)?;
let after = Instant::now();
create_rewriter_output(out, script_url, js.to_string(), after - before)
create_rewriter_output(out, script_url, js, after - before)
}