@@ -97,20 +97,29 @@ export function isStringLoc(loc: UrlValue): loc is string {
9797
9898export function tryGetRemoteLocation (
9999 loc : UrlValue | undefined ,
100- fileLinkPrefix : string
100+ fileLinkPrefix : string ,
101+ sourceLocationPrefix : string ,
101102) : string | undefined {
102103 const resolvableLocation = tryGetResolvableLocation ( loc ) ;
103104 if ( ! resolvableLocation ) {
104105 return undefined ;
105106 }
106107
107- // Remote locations have the following format:
108- // file:/home/runner/work/<repo>/<repo/relative/path/to/file
109- // So we need to drop the first 6 parts of the path.
108+ let trimmedLocation : string ;
110109
111- // TODO: We can make this more robust to other path formats.
112- const locationParts = resolvableLocation . uri . split ( '/' ) ;
113- const trimmedLocation = locationParts . slice ( 6 , locationParts . length ) . join ( '/' ) ;
110+ // Remote locations have the following format:
111+ // "file:${sourceLocationPrefix}/relative/path/to/file"
112+ // So we need to strip off the first part to get the relative path.
113+ if ( sourceLocationPrefix ) {
114+ trimmedLocation = resolvableLocation . uri . replace ( `file:${ sourceLocationPrefix } /` , '' ) ;
115+ } else {
116+ // If the source location prefix is empty (e.g. for older remote queries), we assume that the database
117+ // was created on a Linux actions runner and has the format:
118+ // "file:/home/runner/work/<repo>/<repo/relative/path/to/file"
119+ // So we need to drop the first 6 parts of the path.
120+ const locationParts = resolvableLocation . uri . split ( '/' ) ;
121+ trimmedLocation = locationParts . slice ( 6 , locationParts . length ) . join ( '/' ) ;
122+ }
114123
115124 const fileLink = {
116125 fileLinkPrefix,
0 commit comments