Skip to content

Commit

Permalink
v1.2.3: Decode initiatorType above 9 properly
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed May 9, 2019
1 parent 71184e1 commit 0652411
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# resourcetiming-compression.js

v1.2.2
v1.2.3

[http://nicj.net](http://nicj.net)

Expand Down Expand Up @@ -253,6 +253,8 @@ Or via ``gulp``:

## Version History

* v1.2.3 - 2019-05-09
* Decode `initiatorType` above 9 properly
* v1.2.2 - 2019-05-09
* Add additional `initiatorType` values
* v1.2.1 - 2018-11-26:
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "resourcetiming-compression",
"version": "1.2.2",
"version": "1.2.3",
"homepage": "https://github.com/nicjansma/resourcetiming-compression.js",
"authors": [
"Nic Jansma <nic@nicj.net>",
Expand Down
2 changes: 1 addition & 1 deletion dist/resourcetiming-decompression.min.js

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

2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "ResourceTiming compression and decompression",
"main": "./index.js",
"author": "Nic Jansma",
"version": "1.2.2",
"version": "1.2.3",
"repository": {
"type": "git",
"url": "http://github.com/nicjansma/resourcetiming-compression.js.git"
Expand Down
2 changes: 1 addition & 1 deletion src/resourcetiming-decompression.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@
url = ResourceTimingDecompression.reverseHostname(url);
}

var initiatorType = parseInt(data[0], 10);
var initiatorType = isNaN(parseInt(data[0], 10)) ? data[0] : parseInt(data[0], 10);
data = data.length > 1 ? data.split(ResourceTimingDecompression.SPECIAL_DATA_PREFIX) : [];
var timings = data.length > 0 && data[0].length > 1 ? data[0].substring(1).split(",") : [];
var specialData = data.length > 1 ? data.slice(1) : [];
Expand Down
13 changes: 13 additions & 0 deletions test/test-resourcetiming-decompression.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@

expect(ResourceTimingDecompression.decompressResources(data)).to.eql(expected);
});

it("should decompress the initiatorType for indexes over 9", function() {
var data = {
"abc": "j1,7,6,5,5,4,3,3,2,1,0"
};

// swap in a different initiatorType
var res = getTimestampsFor("abc");
res.initiatorType = "eventsource";
var expected = [res];

expect(ResourceTimingDecompression.decompressResources(data)).to.eql(expected);
});
});

//
Expand Down

0 comments on commit 0652411

Please sign in to comment.