{"action":"created","issue":{"url":"https://api.github.com/repos/racedisparityaudit/rd_cms/issues/806","repository_url":"https://api.github.com/repos/racedisparityaudit/rd_cms","labels_url":"https://api.github.com/repos/racedisparityaudit/rd_cms/issues/806/labels{/name}","comments_url":"https://api.github.com/repos/racedisparityaudit/rd_cms/issues/806/comments","events_url":"https://api.github.com/repos/racedisparityaudit/rd_cms/issues/806/events","html_url":"https://github.com/racedisparityaudit/rd_cms/pull/806","id":371023159,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzNTYzNjg1","number":806,"title":"Fix static site links with trailing slashes","user":{"login":"samuelhwilliams","id":2920760,"node_id":"MDQ6VXNlcjI5MjA3NjA=","avatar_url":"https://avatars1.githubusercontent.com/u/2920760?v=4","gravatar_id":"","url":"https://api.github.com/users/samuelhwilliams","html_url":"https://github.com/samuelhwilliams","followers_url":"https://api.github.com/users/samuelhwilliams/followers","following_url":"https://api.github.com/users/samuelhwilliams/following{/other_user}","gists_url":"https://api.github.com/users/samuelhwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/samuelhwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samuelhwilliams/subscriptions","organizations_url":"https://api.github.com/users/samuelhwilliams/orgs","repos_url":"https://api.github.com/users/samuelhwilliams/repos","events_url":"https://api.github.com/users/samuelhwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/samuelhwilliams/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-10-17T11:19:55Z","updated_at":"2018-10-18T08:12:36Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/racedisparityaudit/rd_cms/pulls/806","html_url":"https://github.com/racedisparityaudit/rd_cms/pull/806","diff_url":"https://github.com/racedisparityaudit/rd_cms/pull/806.diff","patch_url":"https://github.com/racedisparityaudit/rd_cms/pull/806.patch"},"body":" ## Summary\r\nSome of our routes have trailing slashes and others don't (for example,\r\n`/users/` vs `/admin`. This gives us inconsistent URLs and makes it\r\nharder to predict what structure we need when we export the site to\r\nstatic files and upload it to S3. This PR moves us to having **no\r\ntrailing slashes** by default - though also disables Flask's strict\r\nhandling of slashes - so if a trailing slash is provided, it will\r\nredirect to the non-trailing version with a 302. The trailing slash\r\nhistorically implied a directory-like structure, which isn't really what\r\nwe have. We have a set of browsable pages, so sans-slash feels fine.\r\n\r\nGiven that we now also serve our static files from an S3 bucket which is\r\nenabled for web hosting, it will automatically resolve something like\r\n`/users` down to `/users/index.html`, which lets us remove the extra\r\nstep in the s3_deployer that moves index files up a directory level and\r\nflattens them out into just `/users`. This simplifies our build process\r\nand gives us a slightly more standard file layout.\r\n\r\n ## Research\r\nhttps://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html\r\nhttps://www.seoblog.com/2018/05/remove-trailing-slash-urls/\r\nhttps://stackoverflow.com/questions/33241050/trailing-slash-triggers-404-in-flask-path-rule\r\n\r\n ## Deployment process\r\nWhen this goes out, some objects in the S3 bucket will no longer get\r\nupdated, but could potentially get served if the correct URL is hit. We\r\nwill need to manually remove these keys so that S3/CloudFront can start\r\nserving the new ones and redirecting as appropriate. These keys will\r\nmainly be at the top level(s) of the bucket, where keys have been\r\ntranslated from a/b/c/index.html to a/b/c (or whatever).\r\n\r\n ## Ticket\r\nhttps://trello.com/c/0J4BvUYA/1108"},"comment":{"url":"https://api.github.com/repos/racedisparityaudit/rd_cms/issues/comments/430916742","html_url":"https://github.com/racedisparityaudit/rd_cms/pull/806#issuecomment-430916742","issue_url":"https://api.github.com/repos/racedisparityaudit/rd_cms/issues/806","id":430916742,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDkxNjc0Mg==","user":{"login":"frankieroberto","id":30665,"node_id":"MDQ6VXNlcjMwNjY1","avatar_url":"https://avatars0.githubusercontent.com/u/30665?v=4","gravatar_id":"","url":"https://api.github.com/users/frankieroberto","html_url":"https://github.com/frankieroberto","followers_url":"https://api.github.com/users/frankieroberto/followers","following_url":"https://api.github.com/users/frankieroberto/following{/other_user}","gists_url":"https://api.github.com/users/frankieroberto/gists{/gist_id}","starred_url":"https://api.github.com/users/frankieroberto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankieroberto/subscriptions","organizations_url":"https://api.github.com/users/frankieroberto/orgs","repos_url":"https://api.github.com/users/frankieroberto/repos","events_url":"https://api.github.com/users/frankieroberto/events{/privacy}","received_events_url":"https://api.github.com/users/frankieroberto/received_events","type":"User","site_admin":false},"created_at":"2018-10-18T08:12:36Z","updated_at":"2018-10-18T08:12:36Z","author_association":"CONTRIBUTOR","body":"@samuelhwilliams this looks good, and should fix the bug whereby https://www.ethnicity-facts-figures.service.gov.uk/dashboards/whats-new links to https://www.ethnicity-facts-figures.service.gov.uk/dashboards/ (in the breadcrumb) which 404s.\r\n\r\nRegarding S3, my understanding is that we ought not to need to use `/dashboards/index.html` to serve `/dashboards` as you can call the file `dashboards` (no suffix) and set the content type in the http header. (The only exception is for the root homepage).  Arguably this is a bit nicer, as you don't end up with lots of folders with a single file in them.  \r\n\r\nI think one reason why using `.html` suffixed files and `/index.html` directory indexes was that in theory they can be viewed locally over `file://` (although this no longer works) and more easily hosted on another static hosting platform (however we've not really tested this)."}}
{"actor":{"display_login":"frankieroberto"}}