in src/middleware/files.js [183:235]
function providerResult(req, res, p) {
return Promise.resolve()
.then(() => {
const promises = [];
const i18n = req.superstatic.i18n;
if (i18n && i18n.root) {
// The path order is:
// (1) root/language_country/path (for each language)
// (2) root/ALL_country/path (if country is set)
// (3) root/language_ALL/path or root/language/path (for each language)
const country = getCountryCode(req.headers);
const languages = getI18nLanguages(req.headers);
// (1)
if (country) {
for (const l of languages) {
promises.push(
res.superstatic.provider(
req,
pathjoin(i18n.root, `${l}_${country}`, p)
)
);
}
// (2)
promises.push(
res.superstatic.provider(
req,
pathjoin(i18n.root, `ALL_${country}`, p)
)
);
}
// (3)
for (const l of languages) {
promises.push(
res.superstatic.provider(req, pathjoin(i18n.root, `${l}_ALL`, p))
);
promises.push(
res.superstatic.provider(req, pathjoin(i18n.root, `${l}`, p))
);
}
}
promises.push(res.superstatic.provider(req, p));
return Promise.all(promises);
})
.then((results) => {
for (const r of results) {
if (r) {
return r;
}
}
});
}