Skip to content

Commit

Permalink
feat: The urlDataGet function turns in to a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioAR committed Oct 23, 2024
1 parent 933c433 commit d94e983
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 49 deletions.
21 changes: 9 additions & 12 deletions app/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,21 @@ export default function HomePage() {
console.error('Error opening the didcomm URL:', error)
}

const urlDataGet = (urlParams: URLSearchParams | null): string => {
let data = ''
if (null === urlParams) {
return data
const urlData: string = (() => {
if (null === searchParams) {
return ''
}

if (null !== urlParams.get('oob')) {
data = '/?oob=' + urlParams.get('oob')
if (null !== searchParams.get('oob')) {
return '/?oob=' + searchParams.get('oob')
}

if (null !== urlParams.get('_oob')) {
data = '/?_oob=' + urlParams.get('_oob')
if (null !== searchParams.get('_oob')) {
return '/?_oob=' + searchParams.get('_oob')
}

return data
}

const urlData: string = urlDataGet(searchParams)
return ''
})()

return (
<React.Fragment>
Expand Down
33 changes: 8 additions & 25 deletions app/app/privacity/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,21 @@ const Privacity = () => {
setSearchParams(params)
}, [])

const urlDataGet = (urlParams: URLSearchParams | null): string => {
if (null === urlParams) {
const urlData: string = (() => {
if (null === searchParams) {
return ''
}

if (null !== urlParams.get('oob')) {
return '/?oob=' + urlParams.get('oob')
if (null !== searchParams.get('oob')) {
return '/?oob=' + searchParams.get('oob')
}

if (null !== urlParams.get('_oob')) {
return '/?_oob=' + urlParams.get('_oob')
if (null !== searchParams.get('_oob')) {
return '/?_oob=' + searchParams.get('_oob')
}
}

const urlData: string = urlDataGet(searchParams)
let data = ''
if (null === urlParams) {
return data
}

if (null !== urlParams.get('oob')) {
data = '/?oob=' + urlParams.get('oob')
}

if (null !== urlParams.get('_oob')) {
data = '/?_oob=' + urlParams.get('_oob')
}

return data
}

const urlData: string = urlDataGet(searchParams)
return ''
})()

return (
<div
Expand Down
21 changes: 9 additions & 12 deletions app/app/terms/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,21 @@ const Terms = () => {
setSearchParams(params)
}, [])

const urlDataGet = (urlParams: URLSearchParams | null): string => {
let data = ''
if (null === urlParams) {
return data
const urlData: string = (() => {
if (null === searchParams) {
return ''
}

if (null !== urlParams.get('oob')) {
data = '/?oob=' + urlParams.get('oob')
if (null !== searchParams.get('oob')) {
return '/?oob=' + searchParams.get('oob')
}

if (null !== urlParams.get('_oob')) {
data = '/?_oob=' + urlParams.get('_oob')
if (null !== searchParams.get('_oob')) {
return '/?_oob=' + searchParams.get('_oob')
}

return data
}

const urlData: string = urlDataGet(searchParams)
return ''
})()

return (
<div
Expand Down

0 comments on commit d94e983

Please sign in to comment.