@@ -48,7 +48,7 @@ import {
4848} from '../utils/uintarray-encoding' ;
4949import { tabSlugs } from '../app-logic/tabs-handling' ;
5050
51- export const CURRENT_URL_VERSION = 11 ;
51+ export const CURRENT_URL_VERSION = 12 ;
5252
5353/**
5454 * This static piece of state might look like an anti-pattern, but it's a relatively
@@ -1162,6 +1162,34 @@ const _upgraders: {
11621162 processedLocation . query = { } ;
11631163 }
11641164 } ,
1165+ [ 12 ] : (
1166+ processedLocation : ProcessedLocationBeforeUpgrade ,
1167+ profile ?: Profile
1168+ ) => {
1169+ // This version changes the source view parameter from 'sourceView' (filename
1170+ // string) to 'sourceViewIndex' (IndexIntoSourceTable). If we can't convert
1171+ // the filename to a source index, so we just remove the sourceView parameter.
1172+ const { query } = processedLocation ;
1173+ if ( ! ( 'sourceView' in query ) || ! profile || ! profile . shared . sources ) {
1174+ return ;
1175+ }
1176+
1177+ // Try to find the source index for the given filename
1178+ const filename = query . sourceView ;
1179+ const { sources, stringArray } = profile . shared ;
1180+
1181+ // Find the filename string index
1182+ const filenameStringIndex = stringArray . indexOf ( filename ) ;
1183+ if ( filenameStringIndex !== - 1 ) {
1184+ // Find the source index with this filename
1185+ const sourceIndex = sources . filename . indexOf ( filenameStringIndex ) ;
1186+ if ( sourceIndex !== - 1 ) {
1187+ query . sourceViewIndex = sourceIndex ;
1188+ }
1189+ }
1190+ // Remove the old sourceView parameter regardless of whether we found a match
1191+ delete query . sourceView ;
1192+ } ,
11651193} ;
11661194
11671195for ( let destVersion = 1 ; destVersion <= CURRENT_URL_VERSION ; destVersion ++ ) {
0 commit comments