Skip to content

Commit

Permalink
fix: Adjust generateFilePath to include type also for index.php
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jan 25, 2024
1 parent 571c42f commit b47d7fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions __tests__/paths.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ describe('Path generation', () => {
expect(generateFilePath('forms', '', 'index.php')).toBe('/index.php/apps/forms')
})

// TODO: This feels wrong, I would expect `/index.php/apps/forms/templates`
test('non core PHP index files with type', () => {
expect(generateFilePath('forms', 'templates', 'index.php')).toBe('/index.php/apps/forms')
expect(generateFilePath('forms', 'templates', 'index.php')).toBe('/index.php/apps/forms/templates')
})

test('non core PHP file', () => {
Expand Down
11 changes: 5 additions & 6 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,12 @@ export const generateFilePath = (app: string, type: string, file: string) => {
const isCore = window?.OC?.coreApps?.indexOf(app) !== -1
let link = getRootUrl()
if (file.substring(file.length - 3) === 'php' && !isCore) {
link += '/index.php/apps/' + app
link += `/index.php/apps/${app}`
if (type) {
link += `/${encodeURI(type)}`
}
if (file !== 'index.php') {
link += '/'
if (type) {
link += encodeURI(type + '/')
}
link += file
link += `/${file}`
}
} else if (file.substring(file.length - 3) !== 'php' && !isCore) {
link = getAppRootUrl(app)
Expand Down

0 comments on commit b47d7fc

Please sign in to comment.