mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
chore(files): replace encodeFilePath by encodePath from @nextcloud/paths
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
This commit is contained in:
parent
0254af804a
commit
571e06a35c
3 changed files with 7 additions and 20 deletions
|
|
@ -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`)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -21,18 +21,16 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import type { FileStat, ResponseDataDetailed } from 'webdav'
|
||||
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
import { joinPaths } from '@nextcloud/paths'
|
||||
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'
|
||||
import { getCurrentUser } from '@nextcloud/auth'
|
||||
import { joinPaths, encodePath } from '@nextcloud/paths'
|
||||
import moment from '@nextcloud/moment'
|
||||
|
||||
import { encodeFilePath } from '../../../files/src/utils/fileUtils.ts'
|
||||
|
||||
import client from '../utils/davClient.js'
|
||||
import davRequest from '../utils/davRequest.js'
|
||||
import logger from '../utils/logger.js'
|
||||
import type { FileStat, ResponseDataDetailed } from 'webdav'
|
||||
|
||||
export interface Version {
|
||||
fileId: string, // The id of the file associated to the version.
|
||||
|
|
@ -120,7 +118,7 @@ function formatVersion(version: any, fileInfo: any): Version {
|
|||
hasPreview: version.props['has-preview'] === 1,
|
||||
previewUrl,
|
||||
url: joinPaths('/remote.php/dav', version.filename),
|
||||
source: generateRemoteUrl('dav') + encodeFilePath(version.filename),
|
||||
source: generateRemoteUrl('dav') + encodePath(version.filename),
|
||||
fileVersion: version.basename,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue