mirror of
https://github.com/BradNut/umami
synced 2025-09-08 17:40:29 +00:00
Merge pull request #1036 from djyde/support-multiple-track-script-name
support multiple track script name
This commit is contained in:
commit
0e82807170
1 changed files with 6 additions and 1 deletions
|
|
@ -4,10 +4,15 @@ 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;
|
||||
|
||||
if (pathname.endsWith(`/${scriptName}.js`)) {
|
||||
const pathNameParts = pathname.split('/');
|
||||
const lastPathName = pathNameParts[pathNameParts.length - 1];
|
||||
|
||||
if (names.indexOf(lastPathName) !== -1) {
|
||||
url.pathname = '/umami.js';
|
||||
return NextResponse.rewrite(url);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue