Skip to content

Commit afbd4b7

Browse files
committed
we need to use a regex so we can be sure we are removing the final segment of the path... apparently this is still faster than a split/slice/join
1 parent 1857373 commit afbd4b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/get-map-topic-content.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { getLanguageCode } = require('../lib/patterns')
44
// get the childArticles set on map topics in lib/site-tree.js
55
module.exports = function getMapTopicContent (productId, siteTree, currentLanguage, currentVersion, currentPath) {
66
const maptopicPath = currentPath
7-
const categoryPath = currentPath.replace(`/${last(currentPath.split('/'))}`, '')
7+
const categoryPath = currentPath.replace(new RegExp(`/${last(currentPath.split('/'))}$`), '')
88
const siteTreePath = getSiteTreePath(currentVersion, productId, categoryPath, maptopicPath)
99
let childArticles = get(siteTree[currentLanguage], siteTreePath)
1010

@@ -17,7 +17,7 @@ module.exports = function getMapTopicContent (productId, siteTree, currentLangua
1717
}
1818

1919
if (!childArticles) {
20-
console.error('can\'t find child articles for map topic')
20+
console.error(`can\'t find child articles for map topic ${currentPath}`)
2121
return ''
2222
}
2323

0 commit comments

Comments
 (0)