Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
llms_txt: Correct how to translate a conversation URL to API params.
Agnish Bauri80fba130138a
diff --git a/zerver/tests/test_llms_txt.py b/zerver/tests/test_llms_txt.pyindex 178f92b5b35..65e779cd040 100644--- a/zerver/tests/test_llms_txt.py+++ b/zerver/tests/test_llms_txt.py@@ -45,6 +45,10 @@ class LlmsTxtTest(ZulipTestCase):content,)self.assertNotIn("narrow=[", content)+ # The `#narrow/...` URL segments use Zulip's hash-encoding, which+ # the doc must not conflate with the URL-encoding of API requests.+ self.assertIn("hash-encoded", content)+ self.assertNotIn("URL-encoded channel name", content)def test_llms_txt_spectator_access_disabled(self) -> None:"""diff --git a/zerver/views/llms_txt.py b/zerver/views/llms_txt.pyindex f3520ae1957..261dac2581d 100644--- a/zerver/views/llms_txt.py+++ b/zerver/views/llms_txt.py@@ -105,10 +105,12 @@ API requests, use the numeric ID as the `channel` operand (e.g.,string and not the channel name. Channel IDs are stable; channelnames can be renamed.-Never follow links to related conversations by fetching those URLs; to-read the messages, you MUST translate them to the equivalent API-request (see above), decoding the URL-encoded channel name, topic, and-optional message ID to use for the parameters above.+Never follow links to related conversations by fetching those URLs;+translate them to the equivalent API request instead (see above). In a+`#narrow/...` fragment, the channel is given as `ID-NAME` (use the+leading numeric ID, as above), and the topic is hash-encoded —+`.`-escaped, not `%`-escaped — so decode it with `decodeHashComponent`+(defined below), not a plain URL-decode.(`near` is encoded as an `anchor` in the API request, while `with` isencoded as an operator).@@ -120,7 +122,7 @@ fetching a copy of the Zulip web app, which you likely don't have abrowser engine able to run. The following code fromweb/src/internal_url.ts may be helpful for doing the encoding/decoding.-``` ts+```ts// ' and ! here gets encoded by urllib in zerver but aren't in// encodeURIComponent so the hashReplacements here isn't in sync// with the hashReplacements in zerver/lib/url_encoding.py.