Skip to content

Commit

Permalink
replaced extracting modelId numeric value to use array slice to remov…
Browse files Browse the repository at this point in the history
…e polynamial expression warning
  • Loading branch information
pramodcog committed Oct 22, 2024
1 parent aa88006 commit 13c00cc
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ export async function fetchDMModelIdFromRevisionId(
}

function extractNumericId(externalId: string): number | null {
const match = externalId.match(/\d+$/);
return match ? parseInt(match[0], 10) : null;
const lastUnderscoreIndex = externalId.lastIndexOf('_');
if (lastUnderscoreIndex === -1) {
return null;
}
const numericPart = externalId.slice(lastUnderscoreIndex + 1);
return numericPart.length > 0 && !isNaN(Number(numericPart)) ? parseInt(numericPart, 10) : null;
}

function getModelIdQuery(revisionExternalId: string, space: string) {
Expand Down

0 comments on commit 13c00cc

Please sign in to comment.