cryogen-project / cryogen-project/cryogen-core
Bad URLs inferred from titles with non-alpha-numeric characters
- Dominant language
- Clojure
- Stars
- 72
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Description
My apologies, this is a bug I've introduced.
## What breaks
If a page has no embedded metadata, and the metadata is inferred, and the title includes non-alpha-numeric characters, the URL that is generated can include characters that don't link. This is due to to URL encoding, but I'm not sure why URL encoding breaks things.
## The fix
However, the fix I've implemented is very simple:
```diff
index 5061ae3..45e1832 100644
--- a/src/cryogen_core/infer_meta.clj
+++ b/src/cryogen_core/infer_meta.clj
@@ -89,7 +89,7 @@
hyphens substituted for spaces."
[^java.io.File page meta config]
(if (:title meta)
- (str (:date meta) "-" (replace (lower-case (:title meta)) #" +" "-") ".html")
+ (str (:date meta) "-" (replace (lower-case (:title meta)) #"[^a-z0-9]+" "-") ".html")
(let [re-root (re-pattern (str "^.*?(" (:page-root config) "|" (:post-root config) ")/"))
page-fwd (replace (str page) "\\" "/") ;; make it work on Windows
page-name (if (:collapse-subdirs? config)
```
If this fix is acceptable to you, I'll submit a pull request.
Contributor guide
Assessment
This issue has not been assessed yet.