Permission denied.
'; } diff --git a/js/network/url-mapping.js b/js/network/url-mapping.js new file mode 100644 index 0000000..8645c53 --- /dev/null +++ b/js/network/url-mapping.js @@ -0,0 +1,40 @@ +const STORAGE_KEY = 'rep_url_mappings'; + + +function normalizeMappings(mappings) { + if (!Array.isArray(mappings)) return []; + return mappings + .map(mapping => ({ + from: typeof mapping?.from === 'string' ? mapping.from.trim() : '', + to: typeof mapping?.to === 'string' ? mapping.to.trim() : '' + })) + .filter(mapping => mapping.from && mapping.to); +} + +export function getUrlMappings() { + const stored = localStorage.getItem(STORAGE_KEY); + if (stored === null) return []; + + try { + const parsed = JSON.parse(stored); + return normalizeMappings(parsed); + } catch (err) { + localStorage.removeItem(STORAGE_KEY); + return []; + } +} + +export function saveUrlMappings(mappings) { + const normalized = normalizeMappings(mappings); + localStorage.setItem(STORAGE_KEY, JSON.stringify(normalized)); +} + +export function applyUrlMappings(url, mappings = getUrlMappings()) { + for (const mapping of mappings) { + if (!mapping.from || !mapping.to) continue; + if (url.startsWith(mapping.from)) { + return mapping.to + url.slice(mapping.from.length); + } + } + return url; +} diff --git a/js/ui/main-ui.js b/js/ui/main-ui.js index d65725e..1a77eb5 100644 --- a/js/ui/main-ui.js +++ b/js/ui/main-ui.js @@ -16,6 +16,7 @@ export function initUI() { elements.rawRequestInput = document.getElementById('raw-request-input'); elements.useHttpsCheckbox = document.getElementById('use-https'); elements.sendBtn = document.getElementById('send-btn'); + elements.sendBtnLocal = document.getElementById('send-btn-local'); elements.rawResponseDisplay = document.getElementById('raw-response-display'); elements.rawResponseText = document.getElementById('raw-response-text'); elements.hexResponseDisplay = document.getElementById('res-hex-display'); diff --git a/panel.html b/panel.html index 92ae0d2..0bdcb59 100644 --- a/panel.html +++ b/panel.html @@ -87,6 +87,12 @@ Settings + +