From dcaa63e87e95271dd519e1418345f30cc73d0e15 Mon Sep 17 00:00:00 2001 From: Adam Perkins Date: Wed, 30 Nov 2022 18:52:47 -0500 Subject: [PATCH 1/2] added check for > at the beginning of the search path, render the site if present --- src/renderer/context/SearchContext.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/renderer/context/SearchContext.tsx b/src/renderer/context/SearchContext.tsx index 4463100..2757e0e 100644 --- a/src/renderer/context/SearchContext.tsx +++ b/src/renderer/context/SearchContext.tsx @@ -46,16 +46,24 @@ export const SearchContextProvider = ({ const getSearchPath = (searchEnginePath: string, searchPath: string) => { const urlExpression = /(http(s)?:\/\/)[a-zA-Z0-9]+(\.[^\s]{2,})+/; + if (searchPath.match(urlExpression)) { return searchPath; } + // if searchpath starts with >, then don't search, but open the url with https:// or http:// appended + // depending on which one retruns a valid response + if (searchPath.startsWith('>')) { + //test with http:// + const http = searchPath.replace('>', 'http://'); + return http; + } + return searchEnginePath + searchPath; }; const search = () => { const searchKeyword = getSearchPath(searchEngine, keyword); - setUrl(searchKeyword); const newTab: Tab = { tabId: uuidv4(), keyword, From e452725b0b3d051aac05f86ade39c73d5da23277 Mon Sep 17 00:00:00 2001 From: Adam Perkins Date: Wed, 30 Nov 2022 18:55:37 -0500 Subject: [PATCH 2/2] Removed unnecessary comments --- src/renderer/context/SearchContext.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/renderer/context/SearchContext.tsx b/src/renderer/context/SearchContext.tsx index 2757e0e..439b6e2 100644 --- a/src/renderer/context/SearchContext.tsx +++ b/src/renderer/context/SearchContext.tsx @@ -51,10 +51,8 @@ export const SearchContextProvider = ({ return searchPath; } - // if searchpath starts with >, then don't search, but open the url with https:// or http:// appended - // depending on which one retruns a valid response + if (searchPath.startsWith('>')) { - //test with http:// const http = searchPath.replace('>', 'http://'); return http; }