@@ -78,14 +78,29 @@ export default function ExternalLink({ id, isLM, library, publishedName }) {
7878 ) ;
7979 }
8080
81- // is an EM library
82- let dataset = library
83- . replace ( / f l y e m _ / i, "" )
84- . toLowerCase ( )
85- . replace ( "_v" , ":v" )
86- . replace ( / \s + / g, "_" ) ;
87-
88- // TODO: fix the pre-release site dataset since it shouldn't be missing the
81+ // This is an EM library, so process with alternative logic
82+
83+ // The ids are in the format of library:vX:idnumber, eg: male-cns:v0.9:17253
84+ // We need to extract the dataset from the bodyId to construct the neuprint link
85+ // eg: id = male-cns:v0.9:17253 -> dataset = male-cns:v0.9 ; bodyId = 17253
86+ // This can be accomplished by splitting on the second colon and using the first part as
87+ // the dataset and the last part as the bodyId
88+ let dataset ;
89+ let bodyId ;
90+
91+ const match = id . match ( / ^ ( [ ^ : ] * : [ ^ : ] * ) : ( .* ) $ / ) ;
92+ if ( ! match ) { // Fallback if the id doesn't match the expected fully qualified id format
93+ dataset = library
94+ . replace ( / f l y e m _ / i, "" )
95+ . toLowerCase ( )
96+ . replace ( "_v" , ":v" )
97+ . replace ( / \s + / g, "_" ) ;
98+ bodyId = id . split ( ":" ) . pop ( ) ;
99+ } else {
100+ [ , dataset , bodyId ] = match ;
101+ }
102+
103+ // TODO: fix the pre-release site dataset since it shouldn't be missing the
89104 // version number, but the pre-release site doesn't have a version number.
90105 // Also, the pre-release data on neuprint was called vnc and not manc, so the
91106 // dataset name needs to be converted as well.
@@ -105,7 +120,7 @@ export default function ExternalLink({ id, isLM, library, publishedName }) {
105120 : "https://neuprint.janelia.org/view?dataset=<DATASET>&bodyid=<NAME>" ;
106121
107122 const finalEMUrl = emUrl
108- . replace ( / < N A M E > / , id . split ( ":" ) . slice ( - 1 ) )
123+ . replace ( / < N A M E > / , bodyId )
109124 . replace ( / < D A T A S E T > / , dataset ) ;
110125
111126 const secondaryLink = library . match ( / f l y w i r e _ f a f b / i) ? (
0 commit comments