diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-02-22 10:06:52 +0100 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-02-22 23:26:22 +0100 |
commit | 571e06a35c2b26122979d6862914e21967e006fb (patch) | |
tree | aa74fdbef63a8995b0ff4407ae97d612bdf8a3b6 /apps/files | |
parent | 0254af804aa8e24248567107f00130e508b96270 (diff) | |
download | nextcloud-server-571e06a35c2b26122979d6862914e21967e006fb.tar.gz nextcloud-server-571e06a35c2b26122979d6862914e21967e006fb.zip |
chore(files): replace `encodeFilePath` by `encodePath` from `@nextcloud/paths`
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/src/components/TemplatePreview.vue | 4 | ||||
-rw-r--r-- | apps/files/src/utils/fileUtils.ts | 13 |
2 files changed, 3 insertions, 14 deletions
diff --git a/apps/files/src/components/TemplatePreview.vue b/apps/files/src/components/TemplatePreview.vue index 53195d028c6..8418b1c365b 100644 --- a/apps/files/src/components/TemplatePreview.vue +++ b/apps/files/src/components/TemplatePreview.vue @@ -47,8 +47,8 @@ </template> <script> +import { encodePath } from '@nextcloud/paths' import { generateUrl } from '@nextcloud/router' -import { encodeFilePath } from '../utils/fileUtils.ts' import { getToken, isPublic } from '../utils/davUtils.js' // preview width generation @@ -124,7 +124,7 @@ export default { } // TODO: find a nicer standard way of doing this? if (isPublic()) { - return generateUrl(`/apps/files_sharing/publicpreview/${getToken()}?fileId=${this.fileid}&file=${encodeFilePath(this.filename)}&x=${previewWidth}&y=${previewWidth}&a=1`) + return generateUrl(`/apps/files_sharing/publicpreview/${getToken()}?fileId=${this.fileid}&file=${encodePath(this.filename)}&x=${previewWidth}&y=${previewWidth}&a=1`) } return generateUrl(`/core/preview?fileId=${this.fileid}&x=${previewWidth}&y=${previewWidth}&a=1`) }, diff --git a/apps/files/src/utils/fileUtils.ts b/apps/files/src/utils/fileUtils.ts index 126739242a0..1f7e3078da9 100644 --- a/apps/files/src/utils/fileUtils.ts +++ b/apps/files/src/utils/fileUtils.ts @@ -19,9 +19,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ +import { basename, extname } from 'path' import { FileType, type Node } from '@nextcloud/files' import { translate as t, translatePlural as n } from '@nextcloud/l10n' -import { basename, extname } from 'path' // TODO: move to @nextcloud/files /** @@ -41,17 +41,6 @@ export const getUniqueName = (name: string, otherNames: string[], suffix = (n: n return newName } -export const encodeFilePath = function(path) { - const pathSections = (path.startsWith('/') ? path : `/${path}`).split('/') - let relativePath = '' - pathSections.forEach((section) => { - if (section !== '') { - relativePath += '/' + encodeURIComponent(section) - } - }) - return relativePath -} - /** * Extract dir and name from file path * |