Skip to content

Commit

Permalink
Add wildcard support to webchannels
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjduffy committed Dec 14, 2023
1 parent abf2e86 commit 866c141
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion devtools/server/actors/replay/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,12 @@ function initializeRecordingWebChannel() {
);
const localUrl = "http://localhost:8080/";

registerWebChannel(/^https:\/\/.+.replay.io$/);
registerWebChannel(pageUrl);
registerWebChannel(localUrl);

function registerWebChannel(url) {
const urlForWebChannel = Services.io.newURI(url);
const urlForWebChannel = url instanceof RegExp ? url : Services.io.newURI(url);
const channel = new WebChannel("record-replay-token", urlForWebChannel);

channel.listen((...args) => handleAuthChannelMessage(channel, ...args));
Expand Down
4 changes: 4 additions & 0 deletions toolkit/modules/WebChannel.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ var WebChannel = function(id, originOrPermission) {
// restrict based on the site's origin, not on other origin attributes
// such as containers or private browsing.
this._originCheckCallback = requestPrincipal => {
if (originOrPermission instanceof RegExp) {
return originOrPermission.test(requestPrincipal.originNoSuffix);
}

return originOrPermission.prePath === requestPrincipal.originNoSuffix;
};
}
Expand Down

0 comments on commit 866c141

Please sign in to comment.