cryogen-project / cryogen-project/cryogen-core

Bad URLs inferred from titles with non-alpha-numeric characters

Open
#174 1 comment 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.