Skip to content

Commit

Permalink
Revert "Fix url escaping"
Browse files Browse the repository at this point in the history
This reverts commit edbf769.

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Feb 11, 2020
1 parent 36b001e commit 0208dd5
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 44 deletions.
38 changes: 19 additions & 19 deletions js/viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer.js.map

Large diffs are not rendered by default.

17 changes: 1 addition & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"dependencies": {
"@nextcloud/auth": "^1.2.1",
"@nextcloud/axios": "^1.3.1",
"@nextcloud/paths": "^1.1.0",
"@nextcloud/router": "^1.0.0",
"@nextcloud/vue": "^1.3.0",
"camelcase": "^5.3.1",
Expand Down
5 changes: 1 addition & 4 deletions src/services/FileInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
*/

import client from './DavClient'
import { encodePath } from '@nextcloud/paths'
import { genFileInfo } from '../utils/fileUtils'

/**
* Retrieve the files list
*
Expand All @@ -32,7 +30,7 @@ import { genFileInfo } from '../utils/fileUtils'
* @returns {Array} the file list
*/
export default async function(path, options) {
const response = await client.stat(encodePath(path), Object.assign({
const response = await client.stat(path, Object.assign({
data: `<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns"
Expand Down Expand Up @@ -61,6 +59,5 @@ export default async function(path, options) {
</d:propfind>`,
details: true,
}, options))

return genFileInfo(response.data)
}
3 changes: 1 addition & 2 deletions src/services/FileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

import client from './DavClient'
import { encodePath } from '@nextcloud/paths'
import { genFileInfo } from '../utils/fileUtils'

/**
Expand All @@ -35,7 +34,7 @@ export default async function(path, options) {
// getDirectoryContents doesn't accept / for root
const fixedPath = path === '/' ? '' : path

const response = await client.getDirectoryContents(encodePath(fixedPath), Object.assign({
const response = await client.getDirectoryContents(fixedPath, Object.assign({
data: `<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns"
Expand Down
19 changes: 18 additions & 1 deletion src/utils/fileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@
import camelcase from 'camelcase'
import { isNumber } from './numberUtil'

/**
* Get an url encoded path
*
* @param {String} path the full path
* @returns {string} url encoded file path
*/
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
*
Expand Down Expand Up @@ -102,4 +119,4 @@ const genFileInfo = function(obj) {
return fileInfo
}

export { extractFilePaths, sortCompare, genFileInfo }
export { encodeFilePath, extractFilePaths, sortCompare, genFileInfo }

0 comments on commit 0208dd5

Please sign in to comment.