From dd05c19cd685af5d1d6235aa76a3bd5f35e61eae Mon Sep 17 00:00:00 2001 From: Paul Rosenzweig <paulrosenzweig@users.noreply.github.com> Date: Wed, 10 Jul 2019 14:23:28 -0400 Subject: [PATCH] accept null column in formatUrl (#10314) --- frontend/src/metabase/lib/formatting.js | 10 ++-------- frontend/test/metabase/lib/formatting.unit.spec.js | 9 +++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/src/metabase/lib/formatting.js b/frontend/src/metabase/lib/formatting.js index eb4ae880894..aae0894fe50 100644 --- a/frontend/src/metabase/lib/formatting.js +++ b/frontend/src/metabase/lib/formatting.js @@ -549,16 +549,10 @@ function isDefaultLinkProtocol(protocol) { export function formatUrl( value: Value, - { - jsx, - rich, - view_as = "auto", - link_text, - column: { special_type } = {}, - }: FormattingOptions = {}, + { jsx, rich, view_as = "auto", link_text, column }: FormattingOptions = {}, ) { const url = String(value); - const urlSpecialType = isa(special_type, TYPE.URL); + const urlSpecialType = column && isa(column.special_type, TYPE.URL); const protocol = getUrlProtocol(url); if ( jsx && diff --git a/frontend/test/metabase/lib/formatting.unit.spec.js b/frontend/test/metabase/lib/formatting.unit.spec.js index 7104972bf0d..f56cf39da1e 100644 --- a/frontend/test/metabase/lib/formatting.unit.spec.js +++ b/frontend/test/metabase/lib/formatting.unit.spec.js @@ -265,5 +265,14 @@ describe("formatting", () => { }), ).toEqual("data:text/plain;charset=utf-8,hello%20world"); }); + it("should not crash if column is null", () => { + expect( + formatUrl("foobar", { + jsx: true, + rich: true, + column: null, + }), + ).toEqual("foobar"); + }); }); }); -- GitLab