Skip to content

Commit

Permalink
chore: stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
reinamora137 committed Sep 11, 2024
1 parent edb9feb commit bd7fbc6
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/create_issue_from_discussion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,18 @@ jobs:
'indexer': 'stampchain-io/btc_stamps',
};
// Function to sanitize strings
const sanitizeString = (str) => {
return str
.replace(/`/g, '\\`') // Escape backticks
.replace(/\$/g, '\\$') // Escape dollar signs
.replace(/\n/g, '\\n') // Escape newlines
.trim();
};
// Function to safely stringify content
const safeStringify = (obj) => JSON.stringify(obj).replace(/[^\w\s-]/g, '');
if (repoMap[label]) {
const [owner, repo] = repoMap[label].split('/');
// Generate a unique ID
const uniqueId = `DI-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
// Sanitize title and body
const safeTitle = sanitizeString(discussion.title);
const safeBody = sanitizeString(discussion.body);
// Safely stringify title and body
const safeTitle = safeStringify(discussion.title);
const safeBody = safeStringify(discussion.body);
// Create issue
const issue = await github.rest.issues.create({
Expand Down

0 comments on commit bd7fbc6

Please sign in to comment.