@@ -993,17 +993,18 @@ impl FunctionAnalyzer<'_> {
993
993
}
994
994
995
995
fn resolve_jira_api_type ( url : & str ) -> Option < IntrinsicName > {
996
+ // Pattern matching to classify, eg: api.[asApp | asUser]().requestJira(route`/rest/api/3/myself`);
996
997
match url {
997
998
url if url. starts_with ( "/rest/servicedeskapi/" ) => {
998
999
Some ( IntrinsicName :: RequestJiraServiceManagement )
999
1000
}
1000
1001
url if url. starts_with ( "/rest/agile/" ) => Some ( IntrinsicName :: RequestJiraSoftware ) ,
1001
1002
// Accept Jira API v2.0 or v3.0
1002
- url if url. starts_with ( "/rest/api/3 /" ) || url. starts_with ( "/rest/api/2 /" ) => {
1003
+ url if url. starts_with ( "/rest/api/2 /" ) || url. starts_with ( "/rest/api/3 /" ) => {
1003
1004
Some ( IntrinsicName :: RequestJira )
1004
1005
}
1005
1006
_ => {
1006
- warn ! ( "Invalid Jira API URL format : {} " , url) ;
1007
+ warn ! ( "Provided Jira API URL: {:?} is neither Jira, JS, JSM! " , url) ;
1007
1008
None
1008
1009
}
1009
1010
}
@@ -1024,21 +1025,19 @@ impl FunctionAnalyzer<'_> {
1024
1025
let function_name = if * last == "requestJira" {
1025
1026
// Resolve Jira API requests to either JSM/JS/Jira as all are bundled within requestJira()
1026
1027
match first_arg {
1027
- Expr :: Tpl ( template) => {
1028
- let url = template
1029
- . quasis
1030
- . iter ( )
1031
- . map ( |quasi| quasi. raw . as_str ( ) )
1032
- . collect :: < String > ( ) ;
1033
-
1034
- resolve_jira_api_type ( & url) . unwrap_or_else ( || {
1035
- warn ! ( "Falling back to any Jira request" ) ;
1036
- IntrinsicName :: RequestJiraAny
1037
- } )
1028
+ Expr :: TaggedTpl ( TaggedTpl { tpl, .. } ) => {
1029
+ if let Some ( TplElement { raw, .. } ) = tpl. quasis . first ( ) {
1030
+ resolve_jira_api_type ( raw) . unwrap_or_else ( || {
1031
+ // Conservatively assume any of Jira APIs may be used if we can't statically determine which one
1032
+ warn ! ( "Falling back to any Jira request" ) ;
1033
+ IntrinsicName :: RequestJiraAny
1034
+ } )
1035
+ } else {
1036
+ panic ! ( "No url identifiable to classify requestJira() type" ) ;
1037
+ }
1038
1038
}
1039
1039
_ => {
1040
- // Conservatively assume any of Jira APIs may be used if we can't statically determine which one
1041
- warn ! ( "First parameter to requestJira() is invalid" ) ;
1040
+ warn ! ( "Unable to classify requestJira() type" ) ;
1042
1041
IntrinsicName :: RequestJiraAny
1043
1042
}
1044
1043
}
0 commit comments