You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ur...@apache.org on 2023/02/28 02:40:42 UTC

[pulsar-site] branch fix-19644 created (now e16778310cb)

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

urfree pushed a change to branch fix-19644
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git


      at e16778310cb fix rest api page crash

This branch includes the following new commits:

     new e16778310cb fix rest api page crash

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[pulsar-site] 01/01: fix rest api page crash

Posted by ur...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

urfree pushed a commit to branch fix-19644
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git

commit e16778310cb5490a281692c4f7fc771ff41e82e2
Author: Li Li <ur...@apache.org>
AuthorDate: Tue Feb 28 10:40:31 2023 +0800

    fix rest api page crash
    
    Signed-off-by: Li Li <ur...@apache.org>
---
 src/components/RestApi.js |  7 +------
 src/utils/index.js        | 10 +++++++---
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/components/RestApi.js b/src/components/RestApi.js
index ad648344f87..fe59cb272fc 100644
--- a/src/components/RestApi.js
+++ b/src/components/RestApi.js
@@ -1,4 +1,4 @@
-const React = require("react");
+import * as React from "react";
 import Layout from "@theme/Layout";
 import { getVersion, getApiVersion } from "../utils/index.js";
 
@@ -102,11 +102,6 @@ class RestApi extends React.Component {
       "https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js"
     );
     const script = document.querySelector(".container script");
-    console.log(
-      "script: ",
-      script,
-      "/swagger/" + version + "/" + apiversion + "/swagger.json"
-    );
     wrapper.insertBefore(redoc, script);
     wrapper.insertBefore(redocLink, script);
   }
diff --git a/src/utils/index.js b/src/utils/index.js
index 7232243e5da..e9a0eb156d3 100644
--- a/src/utils/index.js
+++ b/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];
+    }
+  } catch (error) {
+    console.error(error)
+    return "master";
   }
-  return "master";
 }
 
 export function getApiVersion(anchor) {