Skip to content

Commit 23d0ad7

Browse files
committed
DEV-621: ignore IPs and localhost in urls
1 parent e0647da commit 23d0ad7

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/injected.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
const detectors = require('vue-telemetry-analyzer/src/detectors')
44

55
async function analyze () {
6+
if (isBlacklisted(document.location.href)) return
67
const originalHtml = await fetch(document.location.href).then(res => res.text())
78
const context = {
89
originalHtml,
@@ -58,3 +59,9 @@ window.addEventListener('message', function (event) {
5859
})
5960

6061
// postMessage({ from: 'injected', payload: { message: 'hello from injected' } }, '*')
62+
63+
function isBlacklisted (hostname) {
64+
const blacklist = ['localhost']
65+
const likelyIP = Boolean(/\d/.test(hostname.split('.').pop()))
66+
return blacklist.includes(hostname) || likelyIP
67+
}

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { version } = require('./package.json')
99
const path = require('path')
1010

1111
const config = {
12-
devtool: 'source-map',
12+
devtool: 'cheap-source-map',
1313
mode: process.env.NODE_ENV,
1414
context: path.join(__dirname, 'src'),
1515
entry: {

0 commit comments

Comments
 (0)