-
Notifications
You must be signed in to change notification settings - Fork 5
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
Clean up code (drop unreachable code) and minor modernization #565
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,42 +162,37 @@ 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) ?? false | ||
const isPHP = file.slice(-3) === 'php' | ||
let link = getRootUrl() | ||
if (file.substring(file.length - 3) === 'php' && !isCore) { | ||
if (isPHP && !isCore) { | ||
link += `/index.php/apps/${app}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. template strings are more performant on modern browsers than string concatenation (and I think better readable). |
||
if (type) { | ||
link += `/${encodeURI(type)}` | ||
} | ||
if (file !== 'index.php') { | ||
link += `/${file}` | ||
} | ||
} else if (file.substring(file.length - 3) !== 'php' && !isCore) { | ||
} else if (!isPHP && !isCore) { | ||
link = getAppRootUrl(app) | ||
if (type) { | ||
link += '/' + type + '/' | ||
link += `/${type}/` | ||
} | ||
if (link.substring(link.length - 1) !== '/') { | ||
if (link.at(-1) !== '/') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
link += '/' | ||
} | ||
link += file | ||
} else { | ||
if ((app === 'settings' || app === 'core' || app === 'search') && type === 'ajax') { | ||
link += '/index.php/' | ||
} else { | ||
link += '/' | ||
link += '/index.php' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving a |
||
} | ||
if (!isCore) { | ||
link += 'apps/' | ||
} | ||
Comment on lines
-190
to
-192
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could never reached, because the above if-else were covering |
||
if (app !== '') { | ||
app += '/' | ||
link += app | ||
if (app) { | ||
link += `/${app}` | ||
} | ||
if (type) { | ||
link += type + '/' | ||
link += `/${type}` | ||
} | ||
link += file | ||
link += `/${file}` | ||
} | ||
return link | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also equivalent to
file.substring(file.length - 3) === 'php'
, good catch to reuse it