Skip to content

Commit

Permalink
Fix workerstart extra trailing commas (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
vturcotte committed Nov 3, 2022
1 parent 6e4ede5 commit 1d6e991
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/resourcetiming-compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,9 @@
data += ResourceTimingCompression.SPECIAL_DATA_PREFIX
+ ResourceTimingCompression.SPECIAL_DATA_SERVICE_WORKER_TYPE
+ this.toBase36(workerStartOffset)
+ ((fetchStartOffset !== workerStartOffset) ? ("," + this.toBase36(fetchStartOffset)) : "");
+ ((fetchStartOffset !== workerStartOffset) ?
("," + this.toBase36(fetchStartOffset)).replace(/,+$/, "") : "");

}

finalUrl = url = this.trimUrl(e.name, this.trimUrls);
Expand Down
23 changes: 23 additions & 0 deletions test/test-resourcetiming-compression.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,29 @@
});
});

it("Should add trimmed workerStart offset (different than fetchStart)", function() {
var startTime = 1,
workerStart = 1000,
fetchStart = 1,
responseEnd = 2000;

expect(ResourceTimingCompression.compressResourceTiming(null, [{
name: "foo",
initiatorType: "img",
startTime: startTime,
responseEnd: responseEnd,
workerStart: workerStart,
fetchStart: fetchStart
}], { lookup: {} })).to.eql({
restiming: {
"foo": "11,1jj"
+ "*6"
+ (workerStart - startTime).toString(36)
},
servertiming: {}
});
});

it("Should compress http/1.1 nextHopProtocol data", function() {
expect(ResourceTimingCompression.compressResourceTiming(null, [{
name: "foo",
Expand Down

0 comments on commit 1d6e991

Please sign in to comment.