Skip to content

Commit 4d19c4e

Browse files
committed
refact: Migrate $helper.url to TypeScript
1 parent 11bdb13 commit 4d19c4e

File tree

13 files changed

+49
-72
lines changed

13 files changed

+49
-72
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
return [
4-
'source' => 'panel/src/helpers/url.js'
4+
'source' => 'panel/src/helpers/url.ts'
55
];

panel/src/helpers/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import sort from "./sort.js";
1717
import string from "./string";
1818
import throttle from "./throttle";
1919
import upload from "./upload.js";
20-
import url from "./url.js";
20+
import url from "./url";
2121
import writer from "./writer.js";
2222

2323
import "./regex";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import url from "./url.js";
2+
import url from "./url";
33

44
describe("$helper.url.base", () => {
55
it("should return the origin", () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import url from "./url.js";
2+
import url from "./url";
33

44
describe("$helper.url.buildQuery", () => {
55
it("should build query", () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import url from "./url.js";
2+
import url from "./url";
33

44
describe("$helper.url.buildUrl", () => {
55
it("should build Url", () => {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import url from "./url.js";
2+
import url from "./url";
33

44
describe("$helper.url.isAbsolute", () => {
55
it("should work", () => {

panel/src/helpers/url.isSameOrigin.test.js renamed to panel/src/helpers/url.isSameOrigin.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { describe, expect, it } from "vitest";
2-
import url from "./url.js";
1+
import { describe, expect, it, vi } from "vitest";
2+
import url from "./url";
33

44
describe("$helper.url.isSameOrigin", () => {
5-
window.location = new URL("https://test.com");
5+
vi.stubGlobal("location", new URL("https://test.com"));
66

77
it("should detect same origin", () => {
88
const input = "https://test.com";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import url from "./url.js";
2+
import url from "./url";
33
import urls from "@/../../tests/Toolkit/fixtures/urls.json";
44

55
describe("$helper.url.isUrl", () => {

panel/src/helpers/url.makeAbsolute.test.js renamed to panel/src/helpers/url.makeAbsolute.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { describe, expect, it } from "vitest";
2-
import url from "./url.js";
1+
import { describe, expect, it, vi } from "vitest";
2+
import url from "./url";
33

44
describe("$helper.url.makeAbsolute", () => {
55
it("should not touch absolute URLs", () => {
@@ -8,7 +8,7 @@ describe("$helper.url.makeAbsolute", () => {
88
});
99

1010
it("should make URLs absolute", () => {
11-
window.location = new URL("https://getkirby.com");
11+
vi.stubGlobal("location", new URL("https://getkirby.com"));
1212

1313
const result = url.makeAbsolute("/foo");
1414
expect(result).toStrictEqual("https://getkirby.com/foo");
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import url from "./url.js";
2+
import url from "./url";
33

44
describe("$helper.url.toObject", () => {
55
it("should convert string", () => {

0 commit comments

Comments
 (0)