Skip to content

Commit 9d02d50

Browse files
committed
fix: don't add unnecessary trailing slashes
1 parent 6c52a59 commit 9d02d50

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deno.lock # this is a deno library
1+
deno.lock

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Or, add it to your deno.json's (or deno.jsonc) tasks:
1515
You can even add a github action:
1616
https://github.com/LeoDog896/deno-outdated/blob/main/.github/workflows/update.yml
1717

18-
Do note that if you're running an application, remove the run action that removes deno.lock `rm deno.lock`, as that is only for libraries
18+
Do note that if you're running an application, remove the run action that
19+
removes deno.lock `rm deno.lock`, as that is only for libraries
1920

2021
## Flags
2122

redirect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export async function checkRedirect(url: string): Promise<string | undefined> {
88
await response.body?.cancel();
99

1010
if (response.redirected) {
11-
return response.url + (url.endsWith("/") ? "/" : "");
11+
return response.url +
12+
(url.endsWith("/") && !response.url.endsWith("/") ? "/" : "");
1213
} else {
1314
return undefined;
1415
}

test/change.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ Deno.test("Slash at the end of a URL isn't removed", async () => {
4141
const source = `https://esm.sh/preact@10.10.6/`; // i-deno-outdated
4242
const result = await findAndReplace(source);
4343

44+
// https://github.com/LeoDog896/deno-outdated/issues/18
45+
assert(
46+
!result.endsWith("//"),
47+
"Result ends with two slashes '//': " + result,
48+
);
49+
4450
assert(
4551
result.endsWith("/"),
4652
"Result doesn't end with '/': " + result,

0 commit comments

Comments
 (0)