Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust generateFilePath to include type also for index.php #566

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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