From b5ed81b349f2ebf241faeb3f67ba9513102711fc Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 31 Jan 2024 14:04:54 +0800 Subject: [PATCH] fix: invalid server tool url caused crash (#2311) --- .../tools/edit-custom-collection-modal/index.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/web/app/components/tools/edit-custom-collection-modal/index.tsx b/web/app/components/tools/edit-custom-collection-modal/index.tsx index 6c15e827f8..7f05e5ed8a 100644 --- a/web/app/components/tools/edit-custom-collection-modal/index.tsx +++ b/web/app/components/tools/edit-custom-collection-modal/index.tsx @@ -126,6 +126,19 @@ const EditCustomCollectionModal: FC = ({ }) } + const getPath = (url: string) => { + if (!url) + return '' + + try { + const path = new URL(url).pathname + return path || '' + } + catch (e) { + return url + } + } + return ( <> = ({ {item.operation_id} {item.summary} {item.method} - {item.server_url ? new URL(item.server_url).pathname : ''} + {getPath(item.server_url)}