UNPKG

@progress/sitefinity-nextjs-sdk

Version:

Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.

44 lines (43 loc) 1.31 kB
export function pagerLinkAttributes(href, navigateFunc) { // Private helper for URL validation function isUrlSafe(url) { try { // Allow absolute relative URLs (starting with /) if (url.startsWith('/')) { return true; } // For absolute URLs, validate they have the same host if (url.includes('://')) { const urlObj = new URL(url); if (urlObj.protocol !== 'http:' && urlObj.protocol !== 'https:') { return false; } if (typeof window !== 'undefined' && urlObj.host !== window.location.host) { return false; } return true; } return false; } catch (e) { return false; } } if (typeof window !== 'undefined' && navigateFunc) { return { onClick: (e) => { e.preventDefault(); if (isUrlSafe(href)) { navigateFunc(href); } else { console.error('Navigation prevented to potentially unsafe URL:', href); } }, href }; } return { href }; }