Commits

Luke Plant committed 92b4bc2

Fixed bug with words like "doesn't" in titles becoming "doesn-t" instead of "doesnt" in slugs

  • Participants
  • Parent commits c6951e4

Comments (0)

Files changed (2)

File src/Blog/DBUtils.hs

 
 slugFromTitle title = map toLower $ LB.unpack $
                       regexReplace (LB.pack "-+$") (LB.pack "") $
-                      regexReplace (LB.pack "[^A-Za-z0-9]+") (LB.pack "-") (LB.pack title)
+                      regexReplace (LB.pack "[^A-Za-z0-9]+") (LB.pack "-") $
+                      regexReplace (LB.pack "'") (LB.pack "") (LB.pack title)
 
 makeSlugGeneric cn title table = makeSlugGeneric' cn (slugFromTitle title) table 1
 makeSlugGeneric' cn slugBase table iter = do

File testsuite/Tests/Blog/DBUtils.hs

   quickQuery cn "INSERT INTO slugs (title, slug) VALUES (?, ?);" [toSql title, toSql slug]
 
 slugFromTitle1 =  "this-is-a-title" ~=? (slugFromTitle "This is a % $ /title ^£$")
+slugFromTitle2 =  "doesnt-work" ~=? (slugFromTitle "Doesn't work")
+
 makeSlugGeneric1 =
     withDB (\cn ->
             do
 
 tests = test [
          slugFromTitle1,
+         slugFromTitle2,
          TestCase makeSlugGeneric1
         ]