You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "tisonkun (via GitHub)" <gi...@apache.org> on 2023/02/28 02:58:26 UTC

[GitHub] [pulsar-site] tisonkun commented on a diff in pull request #439: fix rest api page crash

tisonkun commented on code in PR #439:
URL: https://github.com/apache/pulsar-site/pull/439#discussion_r1119525480


##########
src/utils/index.js:
##########
@@ -54,10 +54,14 @@ export function setVersion(version) {
 }
 
 export function getVersion() {
-  if (/version=(\d+\.?\x?)+/.test(location.href)) {
-    return location.href.match(/version=(\d+\.?\x?)+/)[0];
+  try {
+    if (/version=(\d+\.?\x?)+/.test(location.href)) {
+      return location.href.match(/version=((\d+\.?\x?)+)/)[1];
+    }

Review Comment:
   Is it possible we find the query part `version=...&apiversion=..` and match the version key-value pair exactly? Instead of using regexp which is brittle.
   
   And, could you explain what is the inputs and outputs of this function?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org