IE tracker fix

pull/365/head
Voldemart96Rus 2020-11-09 14:28:42 +05:00
parent 580e74d842
commit 233ef6ed25
5 changed files with 17220 additions and 2 deletions

70
lib/ie.js Normal file
View File

@ -0,0 +1,70 @@
//Polyfill for HTMLCollection.forEach and NodeList.forEach
if ('NodeList' in window && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
if ('HTMLCollection' in window && !HTMLCollection.prototype.forEach) {
HTMLCollection.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
//Polyfill fo URL
if (typeof window.URL !== 'function') {
window.URL = function (url) {
let protocol = url.split('//')[0],
comps = url
.split('#')[0]
.replace(/^(https:\/\/|http:\/\/)|(\/)$/g, '')
.split('/'),
host = comps[0],
search = comps[comps.length - 1].split('?')[1],
tmp = host.split(':'),
port = tmp[1],
hostname = tmp[0];
search = typeof search !== 'undefined' ? '?' + search : '';
const params = search
.slice(1)
.split('&')
.map(p => p.split('='))
.reduce((obj, pair) => {
const [key, value] = pair.map(decodeURIComponent);
return { ...obj, [key]: value };
}, {});
return {
hash: url.indexOf('#') > -1 ? url.substring(url.indexOf('#')) : '',
protocol,
host,
hostname,
href: url,
pathname:
'/' +
comps
.splice(1)
.map(function (o) {
return /\?/.test(o) ? o.split('?')[0] : o;
})
.join('/'),
search,
origin: protocol + '//' + host,
port: typeof port !== 'undefined' ? port : '',
searchParams: {
get: p => (p in params ? params[p] : ''),
getAll: () => params,
},
};
};
}
/* Polyfill IE 11 end */

17124
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -96,9 +96,14 @@
"uuid": "^8.3.1"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@formatjs/cli": "^2.13.5",
"@prisma/cli": "2.10.1",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-replace": "^2.3.4",
"@svgr/webpack": "^5.4.0",

View File

@ -1,13 +1,31 @@
import 'dotenv/config';
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel';
import buble from '@rollup/plugin-buble';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'tracker/index.js',
output: {
file: 'public/umami.js',
format: 'iife',
format: 'cjs',
plugins: [
getBabelOutputPlugin({
presets: ['@babel/preset-env'],
plugins: [['@babel/plugin-transform-runtime', { useESModules: true }]],
}),
],
},
plugins: [resolve(), buble({ objectAssign: true }), terser({ compress: { evaluate: false } })],
plugins: [
resolve(),
commonjs(),
babel({
babelHelpers: 'bundled',
presets: ['@babel/preset-env'],
}),
buble({ objectAssign: true, target: { ie: 9 } }),
terser({ compress: { evaluate: false } }),
],
};

View File

@ -1,3 +1,4 @@
import '../lib/ie';
import { doNotTrack, hook } from '../lib/web';
import { removeTrailingSlash } from '../lib/url';