-
Notifications
You must be signed in to change notification settings - Fork 19
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
GPII-4410: Opening BYOB web links in an existing tab. #202
Open
stegru
wants to merge
9
commits into
GPII:master
Choose a base branch
from
stegru:GPII-4410
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
25732e9
GPII-4386: fix for duplicate custom buttons
krisYanachkov fcd4bd3
Merge remote-tracking branch 'origin/master'
stegru 0f2def9
Merge remote-tracking branch 'upstream/master'
stegru 69550d9
Merge remote-tracking branch 'upstream/master'
stegru 2e60d8e
Merge remote-tracking branch 'upstream/master'
stegru 4ca8964
Merge remote-tracking branch 'upstream/master'
stegru d2c92af
Merge remote-tracking branch 'upstream/master'
stegru 80bde2b
GPII-4410: Opening web links in their existing tab.
stegru a57d80e
GPII-4410: Improved documentation for currentTabRedirect.
stegru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Handles link redirection. | ||
* | ||
* Copyright 2020 Raising the Floor - International | ||
* | ||
* Licensed under the New BSD license. You may not use this file except in | ||
* compliance with this License. | ||
* | ||
* The R&D leading to these results received funding from the | ||
* Department of Education - Grant H421A150005 (GPII-APCP). However, | ||
* these results do not necessarily represent the policy of the | ||
* Department of Education, and you should not assume endorsement by the | ||
* Federal Government. | ||
* | ||
* You may obtain a copy of the License at | ||
* https://github.com/GPII/gpii-app/blob/master/LICENSE.txt | ||
*/ | ||
|
||
"use strict"; | ||
|
||
var fluid = require("infusion"), | ||
URL = require("url").URL; | ||
|
||
var gpii = fluid.registerNamespace("gpii"); | ||
fluid.registerNamespace("gpii.app.linkRedirect"); | ||
|
||
/** | ||
* Handles /redirect, which redirects the browser to the provided url. | ||
* This is a fall-back for the 'open link in existing tab' feature [GPII-4410], where the browser is opened with a | ||
* special link which gets intercepted by a browser extension. The link really points to this handler, so it will | ||
* still work with browsers that don't have the extension installed. | ||
*/ | ||
fluid.defaults("gpii.app.linkRedirect", { | ||
gradeNames: ["kettle.app"], | ||
defaultRedirectUrl: "http://opensametab.morphic.org/redirect/$1", | ||
requestHandlers: { | ||
handle: { | ||
type: "gpii.app.linkRedirect.request", | ||
route: "/redirect/:destination(.*)" | ||
} | ||
} | ||
}); | ||
|
||
fluid.defaults("gpii.app.linkRedirect.request", { | ||
gradeNames: ["kettle.request.http"], | ||
invokers: { | ||
handleRequest: { | ||
funcName: "gpii.app.linkRedirect.handleRequest", | ||
args: [ | ||
"{request}", | ||
"{request}.req.params.destination" | ||
] | ||
} | ||
} | ||
}); | ||
|
||
/** | ||
* Handler for /redirect. Redirects the browser to the given url. | ||
* | ||
* @param {Component} request The request object. | ||
* @param {String} destination The destination URL. | ||
*/ | ||
gpii.app.linkRedirect.handleRequest = function (request, destination) { | ||
try { | ||
// Make sure the url is valid before sending it out. | ||
var url = new URL(destination); | ||
request.res.status(301).redirect(url.href); | ||
} catch (e) { | ||
request.handlerPromise.reject({ | ||
statusCode: 400, | ||
message: e.message | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see where the "refreshsametab.morphic.org" urls are redirected. Is that in configuration somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's sort of in config.
See: https://github.com/GPII/gpii-app/pull/202/files#diff-713841a004bb552ae227e855846d4b04R34-R39