Allow for navigateTo urls to be of mailto or tel url schemes t (#2781)

This commit is contained in:
Hetu Nandu 2021-02-01 13:47:31 +05:30 committed by GitHub
parent 22afbe8971
commit 86cb8cac67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,6 +92,19 @@ export enum NavigationTargetType {
NEW_WINDOW = "NEW_WINDOW",
}
const isValidUrlScheme = (url: string): boolean => {
return (
// Standard http call
url.startsWith("http://") ||
// Secure http call
url.startsWith("https://") ||
// Mail url to directly open email app prefilled
url.startsWith("mailto:") ||
// Tel url to directly open phone app prefilled
url.startsWith("tel:")
);
};
function* navigateActionSaga(
action: {
pageNameOrUrl: string;
@ -131,9 +144,9 @@ function* navigateActionSaga(
AnalyticsUtil.logEvent("NAVIGATE", {
navUrl: pageNameOrUrl,
});
// Add a default protocol if it doesn't exist.
let url = pageNameOrUrl + convertToQueryParams(params);
if (url.indexOf("://") === -1) {
// Add a default protocol if it doesn't exist.
if (!isValidUrlScheme(url)) {
url = "https://" + url;
}
if (target === NavigationTargetType.SAME_WINDOW) {