Skip to content

Commit e8f03a1

Browse files
authored
Add filename as a URL part (#183)
1 parent 4f76581 commit e8f03a1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/columns/url-parts.ts

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const parts: Record<string, (url: URL) => string> = {
77
protocol: x => x.protocol,
88
search: x => x.search,
99
hash: x => x.hash,
10+
filename: x => x.pathname.split("/").pop() ?? "",
1011
all: getAllParts,
1112
};
1213

@@ -34,6 +35,10 @@ export default glide
3435
.withTest({ uri: "https://www.glideapps.com/blog", part: "pathname" }, "/blog")
3536
.withTest({ uri: "https://www.glideapps.com?message=hello%20world", part: "message" }, "hello world")
3637

38+
.withTest({ uri: "https://www.glideapps.com/blog/post/123", part: "filename" }, "123")
39+
.withTest({ uri: "https://www.glideapps.com/blog/post/123.pdf", part: "filename" }, "123.pdf")
40+
.withTest({ uri: "https://www.glideapps.com/blog/post/123.pdf?message=hello%20world", part: "filename" }, "123.pdf")
41+
3742
.run(({ uri, part = "all" }) => {
3843
try {
3944
const url = new URL(uri);

0 commit comments

Comments
 (0)