Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Parse permit url #586

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/handlers/payout/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,17 @@ export const handleIssueClosed = async () => {
const shortenRecipient = shortenEthAddress(recipient, `[ CLAIM ${priceInEth} ${tokenSymbol.toUpperCase()} ]`.length);
logger.info(`Posting a payout url to the issue, url: ${payoutUrl}`);
const comment = `### [ **[ CLAIM ${priceInEth} ${tokenSymbol.toUpperCase()} ]** ](${payoutUrl})\n` + "```" + shortenRecipient + "```";
const permitComments = comments.filter((content) => content.body.includes("https://pay.ubq.fi?claim=") && content.user.type == UserType.Bot);
const permitComments = comments.filter((content) => {
if (content.body.includes("https://pay.ubq.fi?claim=") && content.user.type == UserType.Bot) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only check for the base URL without query parameters

const url = new URL(content.body);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to extract the URL from the comment with RegExp because the comment will be in Markdown syntax and includes other text. The example of the comment is in line 152.

const searchParams = new URLSearchParams(url.search);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URLSearchParams are already included in the URL object so no need to parse again.


// Check if the URL contains the specific query parameter
return searchParams.has("claim");
}
return false;
});

if (permitComments.length > 0) {
logger.info(`Skip to generate a permit url because it has been already posted`);
return `Permit generation skipped because it was already posted to this issue.`;
Expand Down
Loading