UNPKG

pulse-ai-utils

Version:

Utility functions and helpers for AI-powered applications

34 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitizeId = sanitizeId; exports.generateContentId = generateContentId; exports.sanitizeContentId = sanitizeContentId; function sanitizeId(id) { return id .replace(/^https?:\/\//i, '') // Remove protocol (case-insensitive) .replace(/\/+$/, '') // Remove trailing slashes .replace(/[\/\s]+/g, '-'); // Replace slashes and spaces with dashes } /** * Generate content-specific IDs based on content type * For places/venues: uses title+location * For other content: uses page+title (existing pattern) */ function generateContentId(content) { const { title, location, source_url, page, category, type } = content; // For places, venues, or any content with location data, use title+location if (location && location.trim()) { return sanitizeId(`${title}+${location}`); } // For other content types, use existing pattern: page/source_url + title const pageIdentifier = page || source_url || 'unknown'; return sanitizeId(`${pageIdentifier}+${title}`); } /** * Legacy function for backward compatibility * @deprecated Use generateContentId instead for new content */ function sanitizeContentId(title, location) { return sanitizeId(`${title}+${location}`); } //# sourceMappingURL=sanitizeId.js.map