Utility functions for extracting URLs and validating Gmail message content, including auth headers.
// Source: https://github.com/career-ops-hq/career-ops | License: MIT | Copyright 2026 Santiago Fernández de Valderrama
// Provided via justclaw.it.com; keep this notice with the code.
// @ts-check
// Pure, side-effect-free Gmail helpers. Ported verbatim from the gmail-helpers
// contributed by @SparshGarg999 in #1203 (with thanks). Files prefixed with _
// are never discovered as plugins.
/**
* Extract all http/https URLs from a string (plain text or HTML). Normalizes
* & and strips trailing punctuation. Dedups.
* @param {string} body
* @returns {string[]}
*/
export function extractUrls(body) {
if (!body) return [];
const urls = [];
const regex = /https?:\/\/[^\s"'<>\(\)]+/gi;
let match;
while ((match = regex.exec(body)) !== null) {
const url = match[0].replace(/[.
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key