Skip to content

Commit

Permalink
Merge pull request #41 from holidayextras/safari-bug-fix
Browse files Browse the repository at this point in the history
Fix async xhr issues in safari
  • Loading branch information
rahulpatel authored Feb 15, 2017
2 parents 1562fab + aa30506 commit 6a7a448
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dist/barometer.ie.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/barometer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/urlSanitiser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module.exports = function (href, hash) {
var safeUrl = (href || '').split('?')[0]
safeUrl = safeUrl.replace(/^https?:\/\//i, '')
if (safeUrl[0] === '/') {
safeUrl = (window.location.host || '').replace(/[^a-z0-9-\/]/gi, '_') + '.' + safeUrl.slice(1).replace(/[^a-z0-9-\/]/gi, '_')
safeUrl = (window.location.host || '').replace(/[^a-z0-9-/]/gi, '_') + '.' + safeUrl.slice(1).replace(/[^a-z0-9-/]/gi, '_')
} else {
safeUrl = safeUrl.split('/')
safeUrl = safeUrl.shift().replace(/[^a-z0-9-\/]/gi, '_') + '.' + safeUrl.join('/').replace(/[^a-z0-9-\/]/gi, '_')
safeUrl = safeUrl.shift().replace(/[^a-z0-9-/]/gi, '_') + '.' + safeUrl.join('/').replace(/[^a-z0-9-/]/gi, '_')
}
if ((hash || '').match(/\?/)) {
safeUrl += hash.split('?')[0].slice(1).replace(/[^a-z0-9-]/gi, '_')
Expand Down
7 changes: 5 additions & 2 deletions lib/xhrStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ window.XMLHttpRequest = function () {
event(req, 'loadend', function (event) {
setTimeout(function () {
readyStateTimes.processed = new Date()
return xhrStats._logMetrics({
var data = {
type: type.toLowerCase(),
url: url,
readyStateTimes: readyStateTimes,
offset: offset,
request: req
})
}
try {
xhrStats._logMetrics(data)
} catch (e) { }
}, 0)
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "barometer",
"version": "1.4.0",
"version": "1.4.1",
"description": "Lightweight module to extract performance metrics from a webpage",
"main": "lib/barometer.js",
"scripts": {
Expand Down

0 comments on commit 6a7a448

Please sign in to comment.