{"id":22409114,"url":"https://github.com/typeclasses/scotty-path-normalizer","last_synced_at":"2025-07-31T20:31:08.427Z","repository":{"id":56877215,"uuid":"152783232","full_name":"typeclasses/scotty-path-normalizer","owner":"typeclasses","description":"Scotty action to redirect to a normalized path (remove trailing slash, \"..\", etc.)","archived":false,"fork":false,"pushed_at":"2019-02-14T04:33:19.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-14T11:28:46.805Z","etag":null,"topics":["haskell","haskell-library","http-server"],"latest_commit_sha":null,"homepage":"https://hackage.haskell.org/package/scotty-path-normalizer","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/typeclasses.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-12T17:06:45.000Z","updated_at":"2023-01-11T01:50:35.000Z","dependencies_parsed_at":"2022-08-20T23:10:34.702Z","dependency_job_id":null,"html_url":"https://github.com/typeclasses/scotty-path-normalizer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/typeclasses/scotty-path-normalizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeclasses%2Fscotty-path-normalizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeclasses%2Fscotty-path-normalizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeclasses%2Fscotty-path-normalizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeclasses%2Fscotty-path-normalizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typeclasses","download_url":"https://codeload.github.com/typeclasses/scotty-path-normalizer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typeclasses%2Fscotty-path-normalizer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266151525,"owners_count":23884436,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","haskell-library","http-server"],"created_at":"2024-12-05T12:06:36.659Z","updated_at":"2025-07-31T20:31:08.096Z","avatar_url":"https://github.com/typeclasses.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scotty path normalizer\n\nThis library provides a [Scotty] action that normalizes the HTTP request target\nas if it were a Unix file path. When the path normalization action detects a\npath that can be simplified in one of the following ways, it issues a [redirect]\nto a more canonical path.\n\n1. Remove trailing slashes: `https://typeclasses.com/contravariance/`\n   becomes `https://typeclasses.com/contravariance`\n2. Remove double slashes: `https://typeclasses.com//web-servers////lesson-4`\n   becomes `https://typeclasses.com/web-servers/lesson-4`\n3. Remove `.` segments, because `.` represents \"the current directory\":\n   `https://typeclasses.com/ghc/./scoped-type-variables` becomes\n   `https://typeclasses.com/ghc/scoped-type-variables`\n4. Remove segments of the form `xyz/..`, because `..` represents \"the parent\n   directory\": `https://typeclasses.com/python/../javascript/monoidal-folds`\n   becomes `https://typeclasses.com/javascript/monoidal-folds`\n\nThe typical way to apply this to your Scotty server is to put\n`addPathNormalizer` at the top of your `ScottyM` app definition.\n\n```haskell\nimport qualified Web.Scotty as Scotty\nimport Web.Scotty.PathNormalizer (addPathNormalizer)\n\nmain :: IO ()\nmain =\n    Scotty.scotty 3000 $\n      do\n        addPathNormalizer\n\n        Scotty.get (Scotty.capture \"/:word\") $\n          do\n            beam \u003c- Scotty.param (Data.Text.Lazy.pack \"word\")\n            Scotty.html $ fold\n                [ Data.Text.Lazy.pack \"\u003ch1\u003eScotty, \"\n                , beam\n                , Data.Text.Lazy.pack \" me up!\u003c/h1\u003e\"\n                ]\n```\n\n  [Scotty]: https://hackage.haskell.org/package/scotty\n\n  [redirect]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypeclasses%2Fscotty-path-normalizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypeclasses%2Fscotty-path-normalizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypeclasses%2Fscotty-path-normalizer/lists"}