mirror of
https://github.com/kremalicious/umami.git
synced 2025-01-05 19:35:43 +01:00
Added option to remove trailing slash from urls.
This commit is contained in:
parent
291db2b107
commit
6a8de2aeec
@ -5,6 +5,7 @@ import { useCors, useSession } from 'lib/middleware';
|
||||
import { getIpAddress } from 'lib/request';
|
||||
import { ok, badRequest } from 'lib/response';
|
||||
import { createToken } from 'lib/crypto';
|
||||
import { removeTrailingSlash } from 'lib/url';
|
||||
|
||||
export default async (req, res) => {
|
||||
await useCors(req, res);
|
||||
@ -37,18 +38,20 @@ export default async (req, res) => {
|
||||
|
||||
await useSession(req, res);
|
||||
|
||||
const { type, payload } = req.body;
|
||||
const {
|
||||
body: { type, payload },
|
||||
session: { website_id, session_id },
|
||||
} = req;
|
||||
|
||||
if (type === 'pageview') {
|
||||
const { url, referrer } = payload;
|
||||
let { url, referrer, event_type, event_value } = payload;
|
||||
|
||||
if (process.env.REMOVE_TRAILING_SLASH) {
|
||||
url = removeTrailingSlash(url);
|
||||
}
|
||||
|
||||
if (type === 'pageview') {
|
||||
await savePageView(website_id, session_id, url, referrer);
|
||||
} else if (type === 'event') {
|
||||
const { url, event_type, event_value } = payload;
|
||||
|
||||
await saveEvent(website_id, session_id, url, event_type, event_value);
|
||||
} else {
|
||||
return badRequest(res);
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { doNotTrack, hook } from '../lib/web';
|
||||
import { removeTrailingSlash } from '../lib/url';
|
||||
import { doNotTrack, hook } from 'lib/web';
|
||||
import { removeTrailingSlash } from 'lib/url';
|
||||
|
||||
(window => {
|
||||
const {
|
||||
|
Loading…
Reference in New Issue
Block a user