mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 23:57:12 +01:00
Refactor multi-script name code. Update languages.
This commit is contained in:
parent
0e82807170
commit
edd1645bab
3 changed files with 11 additions and 15 deletions
|
|
@ -4,15 +4,11 @@ function customScriptName(req) {
|
|||
const scriptName = process.env.TRACKER_SCRIPT_NAME;
|
||||
|
||||
if (scriptName) {
|
||||
const names = scriptName.split(',').map(name => name + '.js');
|
||||
|
||||
const url = req.nextUrl.clone();
|
||||
const { pathname } = url;
|
||||
const names = scriptName.split(',').map(name => (name + '.js').trim());
|
||||
|
||||
const pathNameParts = pathname.split('/');
|
||||
const lastPathName = pathNameParts[pathNameParts.length - 1];
|
||||
|
||||
if (names.indexOf(lastPathName) !== -1) {
|
||||
if (names.find(name => pathname.endsWith(name))) {
|
||||
url.pathname = '/umami.js';
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue