@@ -16,7 +16,7 @@ client.collectDefaultMetrics({ register });
1616const labelNames = [
1717 'host' , 'base_path' , 'method' , 'route' , 'status_code' , 'projectAccessionOrID' , 'UniProtID' ,
1818 'PubChemID' , 'PDBID' , 'InChIKey' , 'ChainSequence' , 'CollectionID' , 'filename' ,
19- 'analysisName'
19+ 'analysisName' , 'md_num'
2020] ;
2121const httpRequestsTotal = new client . Counter ( {
2222 name : 'http_requests_total' ,
@@ -231,10 +231,20 @@ function normalizePath(urlPath, matchers) {
231231 for ( const { specPath, re, paramNames } of matchers . compiled ) {
232232 const match = re . exec ( normalizedStripped ) ;
233233 if ( match ) {
234- const params = { base_path : basePath } ;
234+ const params = { base_path : basePath , md_num : '' } ;
235235 paramNames . forEach ( ( name , i ) => {
236236 params [ name ] = match [ i + 1 ] ;
237237 } ) ;
238+
239+ // Split accessions like A0224.1 into accession + md number label.
240+ if ( typeof params . projectAccessionOrID === 'string' ) {
241+ const mdMatch = params . projectAccessionOrID . match ( / ^ ( .+ ) \. ( \d + ) $ / ) ;
242+ if ( mdMatch ) {
243+ params . projectAccessionOrID = mdMatch [ 1 ] ;
244+ params . md_num = mdMatch [ 2 ] ;
245+ }
246+ }
247+
238248 return { route : specPath , params } ;
239249 }
240250 }
@@ -245,7 +255,7 @@ function normalizePath(urlPath, matchers) {
245255 . replace ( / \/ [ a - f A - F 0 - 9 ] { 24 } ( \/ | $ ) / g, '/{id}$1' ) // MongoDB ObjectIds
246256 . replace ( / \/ [ A - Z 0 - 9 ] + \. [ 0 - 9 ] + ( \/ | $ ) / g, '/{accession}$1' ) ; // accessions like A01X6.1
247257
248- return { route, basePath, params : { base_path : basePath } } ;
258+ return { route, basePath, params : { base_path : basePath , md_num : '' } } ;
249259}
250260
251261// Prefer proxy-provided client IPs when available.
0 commit comments