Skip to content

Commit

Permalink
fix: Optimize and modernize code
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 b42908b commit d238045
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ export const imagePath = (app: string, file: string) => {
* @return {string} URL with webroot for a file in an app
*/
export const generateFilePath = (app: string, type: string, file: string) => {
const isCore = window?.OC?.coreApps?.indexOf(app) !== -1
const isCore = window?.OC?.coreApps?.includes(app)
const isPHP = file.slice(-3) === 'php'
let link = getRootUrl()
if (isPHP && !isCore) {
link += '/index.php/apps/' + app
link += `/index.php/apps/${app}`
if (file !== 'index.php') {
link += '/'
if (type) {
Expand All @@ -163,22 +163,17 @@ export const generateFilePath = (app: string, type: string, file: string) => {
} else if (!isPHP && !isCore) {
link = getAppRootUrl(app)
if (type) {
link += '/' + type + '/'
link += `/${type}/`
}
if (link.substring(link.length - 1) !== '/') {
if (link.at(-1) !== '/') {
link += '/'
}
link += file
} else {
if ((app === 'settings' || app === 'core' || app === 'search') && type === 'ajax') {
link += '/index.php/'
} else {
link += '/'
}
if (app !== '') {
app += '/'
link += app
link += '/index.php'
}
link += `/${app}`
if (type) {
link += type + '/'
}
Expand Down

0 comments on commit d238045

Please sign in to comment.