Skip to content

Commit 0171748

Browse files
committed
#RI-5407 - fix parsing url regex
#RI-5408, #RI-5409 - fix url encoding
1 parent 797a221 commit 0171748

File tree

5 files changed

+6
-4
lines changed

5 files changed

+6
-4
lines changed

redisinsight/desktop/src/lib/app/deep-link.handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const deepLinkHandler = async (from?: string): Promise<undefined | IParse
2222
break
2323
default:
2424
return {
25-
from: encodeURIComponent(from),
25+
from,
2626
target: url.query?.target || '_self',
2727
initialPage: url.query?.initialPage,
2828
} as IParsedDeepLink

redisinsight/ui/src/components/global-url-handler/GlobalUrlHandler.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const GlobalUrlHandler = () => {
6464
search: ''
6565
})
6666
}
67-
} catch (_e) {
67+
} catch {
6868
// do nothing
6969
}
7070
}, [search])

redisinsight/ui/src/electron/components/ConfigElectron/ConfigElectron.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ const ConfigElectron = () => {
4747

4848
const deepLinkAction = (_e: any, url: IParsedDeepLink) => {
4949
if (url.from) {
50+
const fromUrl = encodeURIComponent(url.from)
5051
history.push({
51-
search: `from=${url.from}`
52+
search: `from=${fromUrl}`
5253
})
5354
}
5455
}

redisinsight/ui/src/utils/parseRedisUrl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const parseRedisUrl = (urlString: string = ''): Nullable<ParsedRedisUrl> => {
3434
}
3535

3636
// eslint-disable-next-line no-useless-escape
37-
const redisUrlPattern = /^(redis[s]?):\/\/(?:([^\/]+)?@)?(?:.*@)?([^:\/]+)(?::(\d+))?(?:\/(\d+))?$/
37+
const redisUrlPattern = /^(redis[s]?):\/\/(?:(.+)?@)?(?:.*@)?([^:\/]+)(?::(\d+))?(?:\/(\d+))?$/
3838
const match = urlString.match(redisUrlPattern)
3939

4040
if (!match) {

redisinsight/ui/src/utils/tests/parseRedisUrl.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const parseRedisUrlTests: Array<[string, any]> = [
1414
['localhost:6379', { ...defaultRedisParams, host: 'localhost', port: 6379 }],
1515
['redis://localhost', { ...defaultRedisParams, host: 'localhost' }],
1616
['redis://:@localhost:6380', { ...defaultRedisParams, host: 'localhost', port: 6380 }],
17+
['redis://user:pass/@localhost:6380', { ...defaultRedisParams, host: 'localhost', port: 6380, username: 'user', password: 'pass/' }],
1718
['redis://user:pa@ss@localhost:6380', { ...defaultRedisParams, host: 'localhost', port: 6380, username: 'user', password: 'pa@ss' }],
1819
['redis://us@er:pa@ss@localhost:6380', { ...defaultRedisParams, host: 'localhost', port: 6380, username: 'us@er', password: 'pa@ss' }],
1920
['redis://us@er:pa@:ss@localhost:6380', { ...defaultRedisParams, host: 'localhost', port: 6380, username: 'us@er', password: 'pa@:ss' }],

0 commit comments

Comments
 (0)