removing trailing slash methods

Benchmark created on


Setup

const urls = ["https://jsperf.app/", "https://jsperf.app", "https://learnxinyminutes.com/kotlin/", "https://learnxinyminutes.com/kotlin", 
"https://github.com/supabase/cli/releases/tag/v2.67.1", "https://github.com/supabase/cli/releases/tag/v2.67.1/", "https://transform.tools/json-to-typescript", "https://transform.tools/json-to-typescript/"];

Test runner

Ready to run.

Testing in
TestOps/sec
regex way
for (const url of urls) {
	const u = url.replace(/\/$/, "");
}
ready
slice way
for (const url of urls) {
	const u = url.endsWith("/") ? url.slice(0, -1) : url;
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.