From a78c977658a7a092d2ecbfe87759aa016e3e0e77 Mon Sep 17 00:00:00 2001 From: Ivan Starkov Date: Tue, 8 Oct 2024 11:50:18 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20Some=20symbols=20in=20the=20page?= =?UTF-8?q?=E2=80=99s=20=E2=80=98Dynamic=20path=E2=80=99=20input=20cause?= =?UTF-8?q?=20the=20builder=20to=20crash.=20(#4246)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file --- .../features/sidebar-left/panels/pages/social-utils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.ts b/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.ts index e4b1f2251f65..851fc0ffd90d 100644 --- a/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.ts +++ b/apps/builder/app/builder/features/sidebar-left/panels/pages/social-utils.ts @@ -32,7 +32,11 @@ export const truncate = (pageUrl: string, maxLength = 53) => { }; export const formatUrl = (urlString: string) => { - const url = new URL(urlString); + try { + const url = new URL(urlString); - return `${url.origin}${url.pathname.split("/").join(" › ")}`; + return `${url.origin}${url.pathname.split("/").join(" › ")}`; + } catch { + return urlString; + } };