Skip to content

Commit

Permalink
fix homepage url protocol prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoloureirop committed Jan 27, 2023
1 parent 833e62d commit 2e989af
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/components/Views/BrowserTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import { baseStyles, fontStyles } from '../../../styles/common';
import Logger from '../../../util/Logger';
import onUrlSubmit, {
getHost,
getUrlObj,
prefixUrlWithProtocol,
isTLD,
protocolAllowList,
getAlertMessage,
allowLinkOpen,
getUrlObj,
} from '../../../util/browser';
import {
SPA_urlChangeListener,
Expand Down Expand Up @@ -313,7 +314,8 @@ export const BrowserTab = (props) => {
*/
const isHomepage = useCallback((checkUrl = null) => {
const currentPage = checkUrl || url.current;
const { host: currentHost } = getUrlObj(currentPage);
const prefixedUrl = prefixUrlWithProtocol(currentPage);
const { host: currentHost } = getUrlObj(prefixedUrl);
return currentHost === HOMEPAGE_HOST;
}, []);

Expand Down Expand Up @@ -527,10 +529,9 @@ export const BrowserTab = (props) => {
*/
const go = useCallback(
async (url, initialCall) => {
const hasProtocol = url.match(/^[a-z]*:\/\//) || isHomepage(url);
const sanitizedURL = hasProtocol ? url : `${props.defaultProtocol}${url}`;
const { hostname, query, pathname } = new URL(sanitizedURL);
let urlToGo = sanitizedURL;
const prefixedUrl = prefixUrlWithProtocol(url);
const { hostname, query, pathname } = new URL(prefixedUrl);
let urlToGo = prefixedUrl;
urlToGo = sanitizeUrlInput(urlToGo);
const isEnsUrl = isENSUrl(url);
const { current } = webviewRef;
Expand Down Expand Up @@ -559,7 +560,7 @@ export const BrowserTab = (props) => {
}

setProgress(0);
return sanitizedURL;
return prefixedUrl;
}
handleNotAllowedUrl(urlToGo);
return null;
Expand Down

0 comments on commit 2e989af

Please sign in to comment.