From 53e41bdda8c3ba9b2a4a71f60f52729111460b6e Mon Sep 17 00:00:00 2001 From: 50h100a Date: Tue, 8 Aug 2023 16:12:03 -0400 Subject: [PATCH] Relax URL requirements when Mancer is enabled. --- public/script.js | 4 ++-- public/scripts/textgen-settings.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/public/script.js b/public/script.js index b2a57fd24..7733969b3 100644 --- a/public/script.js +++ b/public/script.js @@ -7774,9 +7774,9 @@ $(document).ready(function () { $("#api_button_textgenerationwebui").click(async function (e) { e.stopPropagation(); if ($("#textgenerationwebui_api_url_text").val() != "") { - let value = formatTextGenURL($("#textgenerationwebui_api_url_text").val().trim()) + let value = formatTextGenURL($("#textgenerationwebui_api_url_text").val().trim(), api_use_mancer_webui); if (!value) { - callPopup('Please enter a valid URL.
WebUI URLs should end with /api', 'text'); + callPopup("Please enter a valid URL.
WebUI URLs should end with /api
Enable 'Relaxed API URLs' to allow other paths.", 'text'); return; } diff --git a/public/scripts/textgen-settings.js b/public/scripts/textgen-settings.js index bb8ebdc48..97ea289e9 100644 --- a/public/scripts/textgen-settings.js +++ b/public/scripts/textgen-settings.js @@ -99,11 +99,17 @@ function selectPreset(name) { saveSettingsDebounced(); } -function formatTextGenURL(value) { +function formatTextGenURL(value, use_mancer) { try { const url = new URL(value); if (!power_user.relaxed_api_urls) { - url.pathname = '/api'; + if (use_mancer) { // If Mancer is in use, only require the URL to *end* with `/api`. + if (!url.pathname.endsWith('/api')) { + return null; + } + } else { + url.pathname = '/api'; + } } return url.toString(); } catch { } // Just using URL as a validation check