Skip to content

Commit

Permalink
fix URL input
Browse files Browse the repository at this point in the history
  • Loading branch information
CoNETProject committed Oct 5, 2023
1 parent a4c3b80 commit 4fcb4f8
Show file tree
Hide file tree
Showing 7 changed files with 2,486 additions and 870 deletions.
54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"@conet.project/seguro-worker-lib": "0.13.8",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.11",
"@mui/material": "^5.14.11",
"@mui/icons-material": "^5.14.12",
"@mui/material": "^5.14.12",
"@react-icons/all-files": "^4.1.0",
"@tippyjs/react": "^4.2.6",
"buffer": "^6.0.3",
Expand All @@ -45,42 +45,42 @@
"web-vitals": "^3.5.0"
},
"devDependencies": {
"@reduxjs/toolkit": "^1.9.5",
"@storybook/addon-actions": "^7.0.8",
"@storybook/addon-essentials": "^7.0.8",
"@storybook/addon-links": "^7.0.8",
"@storybook/node-logger": "^7.0.8",
"@storybook/preset-create-react-app": "^7.0.8",
"@storybook/react": "^7.0.8",
"@testing-library/jest-dom": "^5.16.5",
"@reduxjs/toolkit": "^1.9.7",
"@storybook/addon-actions": "^7.4.6",
"@storybook/addon-essentials": "^7.4.6",
"@storybook/addon-links": "^7.4.6",
"@storybook/node-logger": "^7.4.6",
"@storybook/preset-create-react-app": "^7.4.6",
"@storybook/react": "^7.4.6",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^29.5.1",
"@types/node": "^18.16.3",
"@types/react": "^18.2.5",
"@types/react-document-meta": "^3.0.2",
"@types/react-dom": "^18.2.3",
"@testing-library/user-event": "^14.5.1",
"@types/jest": "^29.5.5",
"@types/node": "^20.8.2",
"@types/react": "^18.2.25",
"@types/react-document-meta": "^3.0.3",
"@types/react-dom": "^18.2.10",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.26",
"@types/uuid": "^9.0.1",
"babel-loader": "^9.1.2",
"concurrently": "^8.0.1",
"@types/styled-components": "^5.1.28",
"@types/uuid": "^9.0.4",
"babel-loader": "^9.1.3",
"concurrently": "^8.2.1",
"cors": "^2.8.5",
"electron": "^24.2.0",
"electron":"^26.2.4",
"eslint-plugin-react-hooks": "^4.6.0",
"express": "^4.18.2",
"modern-normalize": "^1.1.0",
"modern-normalize": "^2.0.0",
"react": "^18.2.0",
"react-document-meta": "^3.0.0-beta.2",
"react-dom": "^18.2.0",
"react-icons": "^4.8.0",
"react-icons": "^4.11.0",
"react-intl": "^6.4.2",
"react-redux": "^8.0.5",
"react-redux": "^8.1.3",
"react-scripts": "^5.0.1",
"styled-components": "^5.3.10",
"typescript": "^5.0.4",
"styled-components": "^6.0.8",
"typescript": "^5.2.2",
"wait-on": "^7.0.1",
"caniuse-lite": "^1.0.30001482"
"caniuse-lite": "^1.0.30001543"
},
"browserslist": {
"production": [
Expand Down
18 changes: 12 additions & 6 deletions src/components/App/Apps/Browse/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type SearchInputProps = {
onChanged: (updateText: string) => void
} & HTMLAttributes<ReactNode>

const top100Films = [
{ label: 'The Shawshank Redemption', year: 1994 }
]
const SearchInput = ({defaultTodo, onUpdate, onChanged}: SearchInputProps) => {
const [searchText, setSearchText] = useState(defaultTodo.searchText)
const intl = useIntl()
Expand All @@ -38,18 +41,21 @@ const SearchInput = ({defaultTodo, onUpdate, onChanged}: SearchInputProps) => {
</IconButton>
</Grid>
<Grid item xs>

<FormControl size="small" fullWidth variant="outlined">
<OutlinedInput sx={{ borderRadius: '20px',fontSize:'small' }}
fullWidth={true}
//placeholder={ defaultTodo.keyID }
placeholder={ intl.formatMessage({id:'platform.app.browser.search.placeholder'})}
startAdornment={
<InputAdornment position="start">
<IconButton>
<SearchIcon/>
</IconButton>
</InputAdornment>

startAdornment= {
<InputAdornment position="start">
<IconButton>
<SearchIcon/>
</IconButton>
</InputAdornment>
}

value={
searchText
}
Expand Down
18 changes: 15 additions & 3 deletions src/components/App/Apps/Browse/searchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ const InjetDom = () => {
)
}


const urlRegExp = /^(?!.*?_.*?)(?!(?:[\d\w]+?\.)?\-[\w\d\.\-]*?)(?![\w\d]+?\-\.(?:[\d\w\.\-]+?))(?=[\w\d])(?=[\w\d\.\-]*?\.+[\w\d\.\-]*?)(?![\w\d\.\-]{254})(?!(?:\.?[\w\d\-\.]*?[\w\d\-]{64,}\.)+?)[\w\d\.\-]+?(?<![\w\d\-\.]*?\.[\d]+?)(?<=[\w\d\-]{2,})(?<![\w\d\-]{25})$/
const localIpAddress = /^(?:127\.|0?10\.|172\.0?1[6-9]\.|172\.0?2[0-9]\.|172\.0?3[01]\.|192\.168\.|169\.254\.|::1|[fF][cCdD][0-9a-fA-F]{2}:|[fF][eE][89aAbB][0-9a-fA-F]:)/
const ipV6Check = /^(?=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$)(?:(?:25[0-5]|[12][0-4][0-9]|1[5-9][0-9]|[1-9]?[0-9])\.?){4}$|(?=^(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}$)(?![^:]*::.+::[^:]*$)(?:(?=.*::.*)|(?=\w+:\w+:\w+:\w+:\w+:\w+:\w+:\w+))(?:(?:^|:)(?:[0-9a-f]{4}|[1-9a-f][0-9a-f]{0,3})){0,8}(?:::(?:[0-9a-f]{1,4}(?:$|:)){0,6})?$/

const SearchPage = (todo: Todo, index: number, currentTab: number, setCurrentTodo: React.Dispatch<React.SetStateAction<Todo>>) => {
const [currectUrl, setCurrectUrl] = useState('')
Expand All @@ -69,8 +71,18 @@ const SearchPage = (todo: Todo, index: number, currentTab: number, setCurrentTod
const onUpdate = ( text: string ) => {

// Search input
if (!/^http/.test(text)) {
text = `https://search.brave.com/search?q=${text}&source=${isTouchDevice ? 'mobile': 'desktop'}`
const spaceSplit = text.split(/ /)
const dotSplit = text.split(/\./)
if (spaceSplit.length < 2 || dotSplit.length > 1) {
logger(`urlRegExp.test(text) = [${urlRegExp.test(text)}]`)
logger(`!localIpAddress.test(text) = [${!localIpAddress.test(text)}]`)
logger(`!ipV6Check.test(text) = [${!ipV6Check.test(text)}]`)
if (urlRegExp.test(text) || !localIpAddress.test(text) || !ipV6Check.test(text)) {

if (!/^https?\:\/\//.test(text)) {
text = `https://${text}`
}
}
}

let remote = new URL(text)
Expand Down
1 change: 0 additions & 1 deletion src/components/App/Apps/Browse/showTodoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ function a11yProps(index: number) {
key: `simple-tab-${index}`
}
}

const ShowSearchTextInput = () => {
const todoContext = useContext(ToDoContext)
const [currectTodo, setCurrentTodo] = useState<Todo>(todoContext.todos[0])
Expand Down
20 changes: 10 additions & 10 deletions src/components/UI/Dropdowns/ProfileDropdown/ProfileDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,16 @@ const ProfileDropdown = ({closeDropdown}: ProfileDropdownProps) => {
balance: currentProfile().tokens.conet.balance,
icon: <LogoIcon size={30} color='grey'/>
},
{
primary: 'CoNETCash',
balance: workerService.data?.CoNETCash ? workerService.data.CoNETCash.Total : 0,
icon: <CNTCashLogoIcon size={30}/>,
},
{
primary: 'USDC',
balance: currentProfile().tokens.usdc.balance,
icon: <USDCLogoIcon size={30} color='grey'/>,
}
// {
// primary: 'CoNETCash',
// balance: workerService.data?.CoNETCash ? workerService.data.CoNETCash.Total : 0,
// icon: <CNTCashLogoIcon size={30}/>,
// },
// {
// primary: 'USDC',
// balance: currentProfile().tokens.usdc.balance,
// icon: <USDCLogoIcon size={30} color='grey'/>,
// }
]
return ret
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/UI/Icons/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
} from 'react-icons/fi'

import {
GoPrimitiveDot
GoPasskeyFill
} from 'react-icons/go'

import {
Expand Down Expand Up @@ -189,7 +189,7 @@ export const PasscodeDot = ({size, color, isPlaceholder}: IconProps & { isPlaceh

return (
<StyledThemeIcon isPlaceholder={isPlaceholder}>
<GoPrimitiveDot size={getSize(size)} color={color || undefined}/>
<GoPasskeyFill size={getSize(size)} color={color || undefined}/>
</StyledThemeIcon>
)
}
Expand Down
Loading

0 comments on commit 4fcb4f8

Please sign in to comment.