mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
Added tests to URL util
This commit is contained in:
parent
17e922b8c5
commit
7605f43f3f
29
quartz/util/url.test.ts
Normal file
29
quartz/util/url.test.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { describe, it } from "node:test"
|
||||
import { getExtFromUrl } from "./url"
|
||||
import assert from "node:assert/strict"
|
||||
|
||||
describe("getExtFromUrl", () => {
|
||||
it("should return the correct file extension from a URL", () => {
|
||||
const url = "https://example.com/image.jpg"
|
||||
const ext = getExtFromUrl(url)
|
||||
assert.strictEqual(ext, ".jpg")
|
||||
})
|
||||
|
||||
it("should return undefined for URLs without an extension", () => {
|
||||
const url = "https://example.com/image"
|
||||
const ext = getExtFromUrl(url)
|
||||
assert.strictEqual(ext, undefined)
|
||||
})
|
||||
|
||||
it("should handle URLs with query parameters", () => {
|
||||
const url = "https://example.com/image.jpg?size=large"
|
||||
const ext = getExtFromUrl(url)
|
||||
assert.strictEqual(ext, ".jpg")
|
||||
})
|
||||
|
||||
it("should handle URLs with hash fragments", () => {
|
||||
const url = "https://example.com/image.jpg#section1"
|
||||
const ext = getExtFromUrl(url)
|
||||
assert.strictEqual(ext, ".jpg")
|
||||
})
|
||||
})
|
||||
Loading…
Reference in New Issue
Block a user