mirror of
https://github.com/PretendoNetwork/BOSS.git
synced 2026-07-19 09:12:13 -05:00
feat(npdl): Support edge cases for country and language-specific files
This commit is contained in:
parent
35f23f710c
commit
ce8f6a1356
|
|
@ -3,7 +3,7 @@ import { getCTRTaskFile } from '@/database';
|
|||
import { config } from '@/config-manager';
|
||||
import { restrictHostnames } from '@/middleware/host-limit';
|
||||
import { getCDNFileAsStream, streamFileToResponse } from '@/cdn';
|
||||
import { handleEtag, sendEtagCacheResponse } from '@/util';
|
||||
import { handleEtag, isValidCountryCode, sendEtagCacheResponse } from '@/util';
|
||||
|
||||
const npdl = express.Router();
|
||||
|
||||
|
|
@ -23,7 +23,26 @@ npdl.get([
|
|||
}>, response) => {
|
||||
const { appID, taskID, countryCode, languageCode, fileName } = request.params;
|
||||
|
||||
const file = await getCTRTaskFile(appID, taskID, fileName, countryCode, languageCode);
|
||||
// * There are some special cases that we need to account for some specific 3DS task files:
|
||||
// *
|
||||
// * 1. The country and language being represented in a single parameter with an underscore :languageCode_:countryCode
|
||||
// * 2. Only the country parameter being set instead of the language
|
||||
// *
|
||||
// * This isn't the standard behavior as it doesn't work for all tasks, only some of them do need it
|
||||
// * (this is so unstandard that you can't officially find tasks which use an underscore with the file list endpoint).
|
||||
// * I'm sure whoever designed this behavior must be the most evil person I've ever met
|
||||
let country: string | undefined;
|
||||
let language: string | undefined;
|
||||
if (countryCode == undefined && languageCode !== undefined && languageCode.includes('_')) {
|
||||
[language, country] = languageCode.split('_');
|
||||
} else if (countryCode == undefined && languageCode !== undefined && isValidCountryCode(languageCode)) {
|
||||
country = languageCode;
|
||||
} else {
|
||||
country = countryCode;
|
||||
language = languageCode;
|
||||
}
|
||||
|
||||
const file = await getCTRTaskFile(appID, taskID, fileName, country, language);
|
||||
|
||||
if (!file) {
|
||||
response.sendStatus(404);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user