File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,6 +246,21 @@ export async function runCode(
246246 return renderResult ( queryResult , dataStyles , options ) ;
247247}
248248
249+ // Simple check to prevent dropping sources named "location"
250+ const isLocation = ( value : unknown ) => {
251+ return value && typeof value === "object" && "url" in value ;
252+ } ;
253+
254+ const stripLocation = ( modelDef : ModelDef ) : ModelDef => {
255+ return JSON . parse ( JSON . stringify ( modelDef ) , ( key , value ) => {
256+ if ( key === "location" && isLocation ( value ) ) {
257+ return undefined ;
258+ } else {
259+ return value ;
260+ }
261+ } ) ;
262+ } ;
263+
249264async function renderResult (
250265 queryResult : Result ,
251266 dataStyles : DataStyles ,
@@ -256,9 +271,9 @@ async function renderResult(
256271 const resultContainerId = crypto . randomUUID ( ) ;
257272 let htmlResult = "" ;
258273 if ( isNextRenderer ) {
259- const script = `
274+ const script = /* javascript */ `
260275 (function() {
261- const modelDef = ${ JSON . stringify ( queryResult . _modelDef ) } ;
276+ const modelDef = ${ JSON . stringify ( stripLocation ( queryResult . _modelDef ) ) } ;
262277 const queryResult = ${ JSON . stringify ( queryResult . _queryResult ) } ;
263278 const element = document.getElementById("${ resultContainerId } ");
264279 const malloyRender = document.createElement("malloy-render");
You can’t perform that action at this time.
0 commit comments