Skip to content

Commit 3fbc2c7

Browse files
committedMar 10, 2024··
fix!: uri encode permalink
Closes #80
1 parent 450e7a3 commit 3fbc2c7

File tree

2 files changed

+18
-0
lines changed
  • lib/tableau/extensions/post_extension/posts
  • test/tableau/extensions/post_extension/posts

2 files changed

+18
-0
lines changed
 

‎lib/tableau/extensions/post_extension/posts/post.ex

+1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ defmodule Tableau.PostExtension.Posts.Post do
6262
|> String.replace("_", "-")
6363
|> String.replace(~r/[^[:alnum:]\/\-.]/, "")
6464
|> String.downcase()
65+
|> URI.encode()
6566
end
6667
end

‎test/tableau/extensions/post_extension/posts/post_test.exs

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ defmodule Tableau.PostExtension.Posts.PostTest do
2121
assert %{permalink: "/blog/articles/foo-man-chu"} = actual
2222
end
2323

24+
test "handles fancy characters in permalink" do
25+
actual =
26+
Post.build(
27+
"some/file/name.md",
28+
%{
29+
title: "¿Qué es la programación funcional?",
30+
type: "articles",
31+
permalink: "/blog/:type/:title",
32+
layout: Some.Layout,
33+
date: "2023-10-13"
34+
},
35+
"hi"
36+
)
37+
38+
assert %{permalink: "/blog/articles/%C2qu%C3-es-la-programaci%C3n-funcional"} = actual
39+
end
40+
2441
test "substitutes date pieces into permalink" do
2542
actual =
2643
Post.build(

0 commit comments

Comments
 (0)
Please sign in to comment.