From 604c1376718e7b9bcf9f25903502633e6c730174 Mon Sep 17 00:00:00 2001 From: flashwave <me@flash.moe> Date: Mon, 21 Apr 2025 00:03:14 +0000 Subject: [PATCH] Take Flashii URL instead of Flashii API url. --- .env.example | 6 +++--- build.js | 2 +- src/mami.js/context.js | 2 +- src/mami.js/flashii.js | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 5ada47d..7b321a0 100644 --- a/.env.example +++ b/.env.example @@ -8,9 +8,9 @@ # Sets the title of the application, might be overridden for the window title by the common settings below once they're loaded #MAMI_TITLE="Flashii Chat" -# Flashii API base URL -# Sets the base URL for Flashii API, without the version part! -#MAMI_API_URL="//flashii.net/api" +# Flashii base URL +# Sets the base URL for Flashii +#MAMI_FII_URL="//flashii.net" # Common configuration location # Contains further information shared by the other chat client diff --git a/build.js b/build.js index 5519cbc..666e30a 100644 --- a/build.js +++ b/build.js @@ -18,7 +18,7 @@ const exec = require('util').promisify(require('child_process').exec); html: { title }, build: { FUTAMI_DEBUG: isDebug, - FII_API: process.env.MAMI_API_URL ?? '//flashii.net/api', + FII_URL: process.env.MAMI_FII_URL ?? '//flashii.net', FUTAMI_URL: process.env.FUTAMI_URL ?? '//futami.flashii.net/common.json', AMI_URL: process.env.AMI_URL ?? '//sockchat.flashii.net', GIT_HASH: (await exec('git log --pretty="%H" -n1 HEAD')).stdout, diff --git a/src/mami.js/context.js b/src/mami.js/context.js index 3d1c226..36247a2 100644 --- a/src/mami.js/context.js +++ b/src/mami.js/context.js @@ -13,7 +13,7 @@ const MamiContext = function(globalEventTarget, eventTarget) { if(typeof eventTarget === 'string') eventTarget = globalEventTarget.scopeTo(eventTarget); - const flashii = new Flashii; + const flashii = new Flashii(`${window.FII_URL}/api`); let isUnloading = false; diff --git a/src/mami.js/flashii.js b/src/mami.js/flashii.js index 2f238f6..0577cd8 100644 --- a/src/mami.js/flashii.js +++ b/src/mami.js/flashii.js @@ -1,7 +1,8 @@ #include xhr.js -const Flashii = function(baseUrl=null) { - baseUrl ??= window.FII_API; +const Flashii = function(baseUrl) { + if(typeof baseUrl !== 'string') + throw new Error('baseUrl must be a string'); if(baseUrl.startsWith('//')) baseUrl = window.location.protocol + baseUrl;