Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wildcard support to webchannels #978

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion devtools/server/actors/replay/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,15 @@ function initializeRecordingWebChannel() {
);
const localUrl = "http://localhost:8080/";

// custom subdomains
registerWebChannel(/^https:\/\/.+.replay.io$/);
// preview branches
registerWebChannel(/^https:\/\/.+-recordreplay.vercel.app$/);
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
Loading