You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
export functionmakeTemplateTag(info: ProtoServiceMethodInfo,noLeadingSlash: boolean=true): t.TemplateLiteral{constroute=info.url.split('/').filter(a=>a!=='').map(a=>{if(a.startsWith('{')){// clean weird routes like this one:// /ibc/apps/transfer/v1/denom_traces/{hash=**}returna.replace(routeRegexForReplace,'')}else{returna;}}).join('/');constsegments=route.split('/');constexpressions: any=[];constquasis=[];letaccumulatedPath='';letisFirst=true;segments.forEach((segment,_index)=>{if(noLeadingSlash&&segment==='')return;if(segment.startsWith('{')&&segment.endsWith('}')){// Dynamic segmentconstparamName=segment.slice(1,-1);// Push the accumulated static text as a quasi before adding the expressionquasis.push(t.templateElement({raw: accumulatedPath+'/',cooked: accumulatedPath},false));accumulatedPath='';// Reset accumulated path after adding to quasis// expressions.push(t.identifier(`params.${paramName}`));expressions.push(t.memberExpression(t.identifier('params'),t.identifier(info.casing?.[paramName] ? info.casing[paramName] : paramName)));// Prepare the next quasi to start with a slash if this is not the last segmentisFirst=false;}else{// Accumulate static text, ensuring to prepend a slash if it's not the first segmentaccumulatedPath+=(isFirst ? '' : '/')+segment;isFirst=false;}});// Add the final accumulated static text as the last quasiquasis.push(t.templateElement({raw: accumulatedPath,cooked: accumulatedPath},true));// Mark the last quasi as tailreturnt.templateLiteral(quasis,expressions);}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: