Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(op_crates/web): regression tests for bugs in old URL implementation #9639

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion cli/tests/unit/url_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts";
import {
assert,
assertEquals,
assertStrictEquals,
assertThrows,
unitTest,
} from "./test_util.ts";

unitTest(function urlParsing(): void {
const url = new URL(
Expand Down Expand Up @@ -470,3 +476,22 @@ unitTest(function emptyPortForSchemeDefaultPort(): void {
url2.protocol = "http";
assertEquals(url2.port, "");
});

unitTest(function assigningPortPropertyAffectsReceiverOnly() {
// Setting `.port` should update only the receiver.
const u1 = new URL("http:https://google.com/");
// deno-lint-ignore no-explicit-any
const u2 = new URL(u1 as any);
u2.port = "123";
assertStrictEquals(u1.port, "");
assertStrictEquals(u2.port, "123");
});

unitTest(function urlSearchParamsIdentityPreserved() {
// URLSearchParams identity should not be lost when URL is updated.
const u = new URL("http:https://foo.com/");
const sp1 = u.searchParams;
u.href = "http:https://bar.com/?baz=42";
const sp2 = u.searchParams;
assertStrictEquals(sp1, sp2);
});