UNPKG

capacitor-cors-bypass-enhanced

Version:

Enhanced Capacitor plugin for CORS bypass with HTTP/2, HTTP/3, gRPC, GraphQL, file operations, and advanced networking features. Modular TypeScript definitions for better maintainability.

47 lines (42 loc) 1.01 kB
import type { InterceptorContext } from '../definitions'; /** * Check if a URL is cross-origin */ export function isCrossOrigin(url: string): boolean { try { const targetUrl = new URL(url); const currentUrl = new URL(window.location.href); return targetUrl.origin !== currentUrl.origin; } catch { return false; } } /** * Create interceptor context */ export function createInterceptorContext(): InterceptorContext { return { startTime: Date.now(), requestId: `req_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, retryCount: 0, data: {}, }; } /** * Utils Manager * Provides utility functions for the web plugin */ export class UtilsManager { /** * Check if a URL is cross-origin */ isCrossOrigin(url: string): boolean { return isCrossOrigin(url); } /** * Create interceptor context */ createInterceptorContext(): InterceptorContext { return createInterceptorContext(); } }