File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { getQueryStore } from '@/stores/Stores'
2020import { getBBoxFromCoord , getBBoxPoints } from '@/utils'
2121import { decodeCoords , encodeCoords } from '@/util/flexPolyline'
2222import { canCompress , deflateB64url , inflateB64url } from '@/util/urlCompress'
23+ import { customModel2prettyString } from '@/sidebar/CustomModelExamples'
2324
2425// Minimum number of (initialized) waypoints before we switch from the legible
2526// `point=lat,lng` format to the compact `fpolyline=` representation. For 1-3
@@ -260,7 +261,13 @@ export default class NavBar {
260261
261262 const customModelStr = await NavBar . parseCustomModel ( url )
262263 if ( customModelStr ) {
263- Dispatcher . dispatch ( new SetCustomModel ( customModelStr , true ) )
264+ // Pretty-print so the editor shows readable JSON (URL form is minified).
265+ // Mirrors QueryStore.getInitialState behaviour for the initial-load case.
266+ let prettyStr = customModelStr
267+ try {
268+ prettyStr = customModel2prettyString ( JSON . parse ( customModelStr ) )
269+ } catch { }
270+ Dispatcher . dispatch ( new SetCustomModel ( prettyStr , true ) )
264271 Dispatcher . dispatch ( new SetCustomModelEnabled ( true ) )
265272 }
266273
Original file line number Diff line number Diff line change @@ -292,7 +292,8 @@ describe('NavBar', function () {
292292 await navBar . updateStateFromUrl ( )
293293
294294 expect ( queryStore . state . customModelEnabled ) . toEqual ( true )
295- expect ( queryStore . state . customModelStr ) . toEqual ( cm )
295+ // stored value is pretty-printed, so compare JSON semantically
296+ expect ( JSON . parse ( queryStore . state . customModelStr ) ) . toEqual ( JSON . parse ( cm ) )
296297 } )
297298
298299 it ( 'parses legacy custom_model= URL' , async ( ) => {
@@ -308,7 +309,7 @@ describe('NavBar', function () {
308309 await navBar . updateStateFromUrl ( )
309310
310311 expect ( queryStore . state . customModelEnabled ) . toEqual ( true )
311- expect ( queryStore . state . customModelStr ) . toEqual ( cm )
312+ expect ( JSON . parse ( queryStore . state . customModelStr ) ) . toEqual ( JSON . parse ( cm ) )
312313 } )
313314
314315 it ( 'sets no points when no points are in URL' , async ( ) => {
You can’t perform that action at this time.
0 commit comments