Skip to content

Commit

Permalink
fix pattern for matching @return tags
Browse files Browse the repository at this point in the history
  • Loading branch information
frangio committed Sep 21, 2022
1 parent 34539d3 commit 44a2296
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/natspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ export function parseNatspec(item: DocItemWithContext): NatSpec {
if (!p.name) {
res.returns.push({ description: content.trim() });
} else {
const paramMatches = content.match(/(\w+) ([^]*)/);
const paramMatches = content.match(/(\w+)( ([^]*))?/);
if (!paramMatches || paramMatches[1] !== p.name) {
throw new Error(`Expected @return tag to start with name '${p.name}'`);
}
const [, name, description] = paramMatches as [string, string, string];
res.returns.push({ name, description: description.trim() });
const [, name, description] = paramMatches as [string, string, string?];
res.returns.push({ name, description: description?.trim() ?? '' });
}
}

Expand Down

0 comments on commit 44a2296

Please sign in to comment.