mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 15:23:38 +01:00
fix pjax, tested on my website
Signed-off-by: 天空Blond <hurui200320@skyblond.info>
This commit is contained in:
parent
13b81bc650
commit
7d3bc66a50
@ -134,19 +134,25 @@ import { removeTrailingSlash } from '../lib/url';
|
||||
|
||||
const handlePush = (state, title, url) => {
|
||||
removeEvents();
|
||||
// url is not guaranteed
|
||||
// thus calling `url.toString()` might causes exception, then break the pjax update
|
||||
// track only if url is validate
|
||||
if (url) {
|
||||
currentRef = currentUrl;
|
||||
const newUrl = url.toString();
|
||||
|
||||
currentRef = currentUrl;
|
||||
const newUrl = url.toString();
|
||||
|
||||
if (newUrl.substring(0, 4) === 'http') {
|
||||
currentUrl = '/' + newUrl.split('/').splice(3).join('/');
|
||||
} else {
|
||||
currentUrl = newUrl;
|
||||
if (newUrl.substring(0, 4) === 'http') {
|
||||
currentUrl = '/' + newUrl.split('/').splice(3).join('/');
|
||||
} else {
|
||||
currentUrl = newUrl;
|
||||
}
|
||||
// this function under some framework might be called multiple times
|
||||
// thus only track if currentUrl and currentRef are not same
|
||||
if (currentUrl !== currentRef) {
|
||||
trackView(currentUrl, currentRef);
|
||||
setTimeout(addEvents, 300);
|
||||
}
|
||||
}
|
||||
|
||||
trackView(currentUrl, currentRef);
|
||||
|
||||
setTimeout(addEvents, 300);
|
||||
};
|
||||
|
||||
/* Global */
|
||||
|
Loading…
Reference in New Issue
Block a user