Skip to content

Commit

Permalink
Fixed a bug where users from the same instance as your own would not …
Browse files Browse the repository at this point in the history
…redirect correctly when the profile was viewed on another instance
  • Loading branch information
Lartsch authored Nov 16, 2022
1 parent 860fc87 commit 1bfc6bf
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,22 @@ function processButton() {
// timeout 1000ms to make it possible to notice the redirection indication
setTimeout(function() {
// build the new url from home instance, user handle and current domain name
// and open the url
if ((handle.match(/@/g) || []).length > 1)
var win = window.open('https://'+instance+'/'+handle, '_blank');
else {
var win = window.open('https://'+instance+'/'+handle+'@'+document.domain, '_blank');
var request;
// if more than 1 @, we have a domain
if ((handle.match(/@/g) || []).length > 1) {
// but if its our own...
if (handle.includes(instance)) {
// ...then we need to remove it
handle = "@"+ handle.split("@")[1];
}
// request string
request = 'https://'+instance+'/'+handle, '_blank';
} else {
// with only 1 @, we have a local handle and need to append to domain
request = 'https://'+instance+'/'+handle+'@'+document.domain, '_blank';
}
// open the window
var win = window.open(request, '_blank');
// focus the new tab if open was successfull
if (win) {
win.focus();
Expand Down

0 comments on commit 1bfc6bf

Please sign in to comment.