MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / wrapUrlsForSlack

Function wrapUrlsForSlack

server/src/addie/security.ts:223–239  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

221 * Only wraps URLs not already inside Slack link syntax (< >).
222 */
223export function wrapUrlsForSlack(text: string): string {
224 // Match bare URLs (http/https) not already wrapped in < >
225 // Use negative lookbehind for < and ensure URL isn't followed by >
226 // Also skip URLs inside backtick code spans
227 return text.replace(
228 /(?<![<`])(https?:\/\/[^\s>)`]+)/g,
229 (match, url, offset) => {
230 // Check if we're inside a backtick code span
231 const before = text.substring(0, offset);
232 const backtickCount = (before.match(/`/g) || []).length;
233 if (backtickCount % 2 === 1) {
234 return match; // Inside code span, don't wrap
235 }
236 return `<${url}>`;
237 }
238 );
239}
240
241export interface BareJsonGuardResult {
242 text: string;

Callers 7

handleUserMessageFunction · 0.85
handleAppMentionFunction · 0.85
handleDirectMessageFunction · 0.85
handleActiveThreadReplyFunction · 0.85
handleChannelMessageFunction · 0.85
handleReactionAddedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected