File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -235,11 +235,16 @@ haskellKeywords = [ "_"
235
235
-- "hallo-welt"
236
236
toSlug :: Text -> Text
237
237
toSlug text =
238
- text
239
- |> map (\ char -> if Char. isAlphaNum char then char else ' ' )
240
- |> toLower
241
- |> words
242
- |> intercalate " -"
238
+ text
239
+ |> toLower
240
+ |> map replaceChar
241
+ |> words
242
+ |> intercalate " -"
243
+ where
244
+ replaceChar 'ä' = ' a'
245
+ replaceChar 'ö' = ' o'
246
+ replaceChar 'ü' = ' u'
247
+ replaceChar char = if Char. isAlphaNum char && Char. isAscii char then char else ' '
243
248
244
249
245
250
-- | Transform a data-field name like @userName@ to a friendly human-readable name like @User name@
Original file line number Diff line number Diff line change @@ -111,3 +111,7 @@ tests = do
111
111
it " should make a slug string from a string" do
112
112
toSlug " IHP Release: 21.08.2020 (v21082020)" `shouldBe` " ihp-release-21-08-2020-v21082020"
113
113
toSlug " Hallo! @ Welt" `shouldBe` " hallo-welt"
114
+
115
+ it " should deal with umlaute" do
116
+ toSlug " käuferpass" `shouldBe` " kauferpass"
117
+ toSlug " äöü" `shouldBe` " aou"
You can’t perform that action at this time.
0 commit comments