diff --git a/frontend/src/metabase/lib/formatting.js b/frontend/src/metabase/lib/formatting.js index eb4ae88089460c9c4d4bfbb5c0f1197c13c4c4d7..aae0894fe5075b3c78936ee8026491fa8a67cea8 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 7104972bf0db1768a658338901e3128c12cf045b..f56cf39da1e026dfcca2606513d14c194ef6eadf 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"); + }); }); });