{"html_url": "https://github.com/simonw/datasette/pull/1648#issuecomment-1059823151", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1648", "id": 1059823151, "node_id": "IC_kwDOBm6k_c4_K54v", "user": {"value": 22429695, "label": "codecov[bot]"}, "created_at": "2022-03-05T19:56:41Z", "updated_at": "2022-03-07T15:38:08Z", "author_association": "NONE", "body": "# [Codecov](https://codecov.io/gh/simonw/datasette/pull/1648?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) Report\n> Merging [#1648](https://codecov.io/gh/simonw/datasette/pull/1648?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (32548b8) into [main](https://codecov.io/gh/simonw/datasette/commit/7d24fd405f3c60e4c852c5d746c91aa2ba23cf5b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (7d24fd4) will **increase** coverage by `0.02%`.\n> The diff coverage is `100.00%`.\n\n[![Impacted file tree graph](https://codecov.io/gh/simonw/datasette/pull/1648/graphs/tree.svg?width=650&height=150&src=pr&token=eSahVY7kw1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)](https://codecov.io/gh/simonw/datasette/pull/1648?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)\n\n```diff\n@@ Coverage Diff @@\n## main #1648 +/- ##\n==========================================\n+ Coverage 92.03% 92.05% +0.02% \n==========================================\n Files 34 34 \n Lines 4557 4570 +13 \n==========================================\n+ Hits 4194 4207 +13 \n Misses 363 363 \n```\n\n\n| [Impacted Files](https://codecov.io/gh/simonw/datasette/pull/1648?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) | Coverage \u0394 | |\n|---|---|---|\n| [datasette/url\\_builder.py](https://codecov.io/gh/simonw/datasette/pull/1648/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3VybF9idWlsZGVyLnB5) | `100.00% <100.00%> (\u00f8)` | |\n| [datasette/utils/\\_\\_init\\_\\_.py](https://codecov.io/gh/simonw/datasette/pull/1648/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3V0aWxzL19faW5pdF9fLnB5) | `94.97% <100.00%> (+0.10%)` | :arrow_up: |\n| [datasette/views/base.py](https://codecov.io/gh/simonw/datasette/pull/1648/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3ZpZXdzL2Jhc2UucHk=) | `95.49% <100.00%> (\u00f8)` | |\n| [datasette/views/table.py](https://codecov.io/gh/simonw/datasette/pull/1648/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3ZpZXdzL3RhYmxlLnB5) | `96.19% <100.00%> (\u00f8)` | |\n\n------\n\n[Continue to review full report at Codecov](https://codecov.io/gh/simonw/datasette/pull/1648?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)\n> `\u0394 = absolute (impact)`, `\u00f8 = not affected`, `? = missing data`\n> Powered by [Codecov](https://codecov.io/gh/simonw/datasette/pull/1648?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Last update [7d24fd4...32548b8](https://codecov.io/gh/simonw/datasette/pull/1648?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1160432941, "label": "Use dash encoding for table names and row primary keys in URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1648#issuecomment-1060067031", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1648", "id": 1060067031, "node_id": "IC_kwDOBm6k_c4_L1bX", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-06T23:50:40Z", "updated_at": "2022-03-06T23:58:31Z", "author_association": "OWNER", "body": "I may have to do extra work here\r\n```python\r\n def database(self, database, format=None):\r\n db = self.ds.databases[database]\r\n if self.ds.setting(\"hash_urls\") and db.hash:\r\n path = self.path(\r\n f\"{dash_encode(database)}-{db.hash[:HASH_LENGTH]}\", format=format\r\n )\r\n else:\r\n path = self.path(dash_encode(database), format=format)\r\n return path\r\n```\r\nThe URLs that incorporate a hash have a `dbname-hash` format - will that `-` in the middle there mess up the dash decoding mechanism? I think it will.\r\n\r\nMight be able to solve that like so:\r\n\r\n```python\r\n async def resolve_db_name(self, request, db_name, **kwargs):\r\n hash = None\r\n name = None\r\n decoded_name = dash_decode(db_name)\r\n if decoded_name not in self.ds.databases and \"-\" in db_name:\r\n # No matching DB found, maybe it's a name-hash?\r\n name_bit, hash_bit = db_name.rsplit(\"-\", 1)\r\n if dash_decode(name_bit) not in self.ds.databases:\r\n raise NotFound(f\"Database not found: {name}\")\r\n else:\r\n name = dash_decode(name_bit)\r\n hash = hash_bit\r\n else:\r\n name = decoded_name\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1160432941, "label": "Use dash encoding for table names and row primary keys in URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1648#issuecomment-1060065736", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1648", "id": 1060065736, "node_id": "IC_kwDOBm6k_c4_L1HI", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-06T23:43:00Z", "updated_at": "2022-03-06T23:43:11Z", "author_association": "OWNER", "body": "> * Maybe use dash encoding for database name too?\r\n\r\nYes, I'm going to do this. At the moment if a DB file is called `fixx%tures.db` when you run it in Datasette the path is `/fix%2525tures` - which is liable to break.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1160432941, "label": "Use dash encoding for table names and row primary keys in URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1648#issuecomment-1060056510", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1648", "id": 1060056510, "node_id": "IC_kwDOBm6k_c4_Ly2-", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-06T23:02:05Z", "updated_at": "2022-03-06T23:04:24Z", "author_association": "OWNER", "body": "Just spotted this: https://github.com/simonw/datasette/blob/de810f49cc57a4f88e4a1553d26c579253ce4531/datasette/views/base.py#L203-L216\r\n\r\nMaybe the db name should use dash encoding too?\r\n\r\nIf so, relevant code includes this bit:\r\n\r\nhttps://github.com/simonw/datasette/blob/de810f49cc57a4f88e4a1553d26c579253ce4531/datasette/url_builder.py#L30-L38", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1160432941, "label": "Use dash encoding for table names and row primary keys in URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1648#issuecomment-1060044592", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1648", "id": 1060044592, "node_id": "IC_kwDOBm6k_c4_Lv8w", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-06T21:42:35Z", "updated_at": "2022-03-06T21:42:35Z", "author_association": "OWNER", "body": "For consistency, I'm going to change how `?_next=` tokens work too. Right now they work like this:\r\n\r\nhttps://github.com/simonw/datasette/blob/de810f49cc57a4f88e4a1553d26c579253ce4531/datasette/views/table.py#L501-L507\r\n\r\nhttps://github.com/simonw/datasette/blob/de810f49cc57a4f88e4a1553d26c579253ce4531/datasette/utils/__init__.py#L114-L116\r\n\r\nI'm going to change those to use dash-encoding instead.\r\n\r\nI considered looking for `%` in those values and replacing that as `-` too, but since Datasette isn't 1.0 yet I'm going to risk breaking any pagination tokens that people might have saved away somewhere!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1160432941, "label": "Use dash encoding for table names and row primary keys in URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1648#issuecomment-1060034562", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1648", "id": 1060034562, "node_id": "IC_kwDOBm6k_c4_LtgC", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-06T20:36:12Z", "updated_at": "2022-03-06T20:36:12Z", "author_association": "OWNER", "body": "Updated documentation: \r\n![image](https://user-images.githubusercontent.com/9599/156941171-89778c12-41bc-4951-97f2-ecc805025a53.png)\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1160432941, "label": "Use dash encoding for table names and row primary keys in URLs"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1648#issuecomment-1060016221", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1648", "id": 1060016221, "node_id": "IC_kwDOBm6k_c4_LpBd", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-03-06T18:37:59Z", "updated_at": "2022-03-06T18:37:59Z", "author_association": "OWNER", "body": "Change of plan: based on extensive conversations on Twitter - see https://github.com/simonw/datasette/issues/1439#issuecomment-1059851259 - I'm going to try a variant of this which is basically percent-encoding but with a hyphen instead of a percent symbol.\r\n\r\nReason being that the current scheme doesn't handle the case of `%` being part of the table name, which could cause weird breakage due to some proxies decoding percent encoding before it gets to Datasette.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1160432941, "label": "Use dash encoding for table names and row primary keys in URLs"}, "performed_via_github_app": null}