Skip to content

Commit 7d3e9ff

Browse files
committed
#RI-4487 - fix incorrect path format
1 parent ded43a6 commit 7d3e9ff

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

redisinsight/ui/src/constants/mocks/mock-guides.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ export const MOCK_GUIDES_ITEMS: IEnablementAreaItem[] = [
3030
args: {
3131
path: 'quick-guides/working-with-hash.html',
3232
},
33+
},
34+
{
35+
type: EnablementAreaComponent.InternalLink,
36+
id: 'working-with-hash-2',
37+
label: 'Working with HASH',
38+
args: {
39+
path: '\\quick-guides\\working-with-hash.html',
40+
},
3341
}
3442
]
3543
},

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/utils/getFileInfo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const getMarkdownPathByManifest = (
9797
if (!manifestPath || !manifest) return pathPrefix
9898
const path = removeManifestPrefix(manifestPath)
9999
const pathToMarkDown = path.replaceAll('/', '.children.')
100-
const markDownPath = get(manifest, pathToMarkDown)?.args?.path
100+
const markDownPath = get(manifest, pathToMarkDown)?.args?.path?.replaceAll('\\', '/')
101101

102102
if (!markDownPath) return ''
103103

@@ -116,7 +116,7 @@ export const getMarkdownPathByManifest = (
116116
return undefined
117117
})
118118

119-
return pathPrefix + folderPath + (markDownPath.match(/^(\/|\\)/) ? markDownPath : '/'.concat(markDownPath))
119+
return pathPrefix + folderPath + (markDownPath.match(/^(\/)/) ? markDownPath : '/'.concat(markDownPath))
120120
}
121121

122122
export const removeManifestPrefix = (path?: string): string => path

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementArea/utils/tests/getFileInfo.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,13 @@ const getMarkdownPathByManifestTests = [
147147
input: [MOCK_GUIDES_ITEMS, '/quick-guides/0/1'],
148148
expected: `/123123-123123${MOCK_GUIDES_ITEMS[0]?.children?.[1]?.args?.path}`
149149
},
150+
{
151+
input: [MOCK_GUIDES_ITEMS, '/quick-guides/0/3'],
152+
expected: '/quick-guides/working-with-hash.html'
153+
},
150154
]
151155

152-
describe('getWBSourcePath', () => {
156+
describe('getMarkdownPathByManifest', () => {
153157
test.each(getMarkdownPathByManifestTests)(
154158
'%j',
155159
({ input, expected }) => {

redisinsight/ui/src/utils/pathUtil.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ export const getRootStaticPath = (mdPath: string) => {
2020
}
2121

2222
const processAbsolutePath = (nodeUrl: string, mdPath: string) => {
23-
// todo: quick fix. find the root cause why path has both '/' and '\'
24-
const normalizedMdPath = mdPath.replaceAll('\\', '/')
25-
const tutorialRootPath = getRootStaticPath(normalizedMdPath)
26-
23+
const tutorialRootPath = getRootStaticPath(mdPath)
2724
return new URL(tutorialRootPath + nodeUrl, getOriginUrl()).toString()
2825
}
2926

0 commit comments

Comments
 (0)