This is an automated email from the ASF dual-hosted git repository.

visortelle pushed a commit to branch rest-api-links
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git

commit a5d1a71ba245d44dab19dc1cb8e9bb782c1a5b59
Author: visortelle <[email protected]>
AuthorDate: Wed Mar 20 21:28:41 2024 +0400

    User the correct curl URLs in docs
---
 docusaurus.config.js | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/docusaurus.config.js b/docusaurus.config.js
index b8d6f18a2502..9fae0ae8b60d 100644
--- a/docusaurus.config.js
+++ b/docusaurus.config.js
@@ -121,8 +121,22 @@ const injectLinkParseForEndpoint = ([, info]) => {
     }
   }
 
+  /**
+   * Removes class name from the REST API docs URL
+   * /admin/v2/<anything>/ClassName_methodName => 
/admin/v2/<anything>/methodName
+   * Context:
+   * - https://github.com/apache/pulsar/issues/21573
+   * - https://github.com/apache/pulsar/pull/19193
+  */
+  function getCurlUrl(path) {
+    const parts = path.split('/');
+    const last = parts[parts.length - 1];
+    const [_, methodName] = last.split('_');
+    return [...parts.slice(0, parts.length - 1), methodName].join('/');
+  }
+
   return {
-    text: method + " " + path,
+    text: method + " " + getCurlUrl(path),
     link: restBaseUrl + "?" + restUrl,
   };
 };

Reply via email to