Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(files): add encodedSource
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Oct 3, 2023
commit 6655f2eec9fafcd70cae5d75b365ccca0983e52c
10 changes: 10 additions & 0 deletions lib/files/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*
*/
import { basename, extname, dirname } from 'path'
import { encodePath } from '@nextcloud/paths'

import { Permission } from '../permissions'
import { FileType } from './fileType'
import { Attribute, NodeData, isDavRessource, validateData } from './nodeData'
Expand Down Expand Up @@ -82,6 +84,14 @@ export abstract class Node {
return this._data.source.replace(/\/$/i, '')
}

/**
* Get the encoded source url to this object for requests purposes
*/
get encodedSource(): string {
const { origin } = new URL(this.source)
return origin + encodePath(this.source.slice(origin.length))
}

/**
* Get this object name
*/
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@
"@nextcloud/auth": "^2.2.1",
"@nextcloud/l10n": "^2.2.0",
"@nextcloud/logger": "^2.7.0",
"@nextcloud/paths": "^2.1.0",
"@nextcloud/router": "^2.1.2",
"is-svg": "^5.0.0",
"webdav": "^5.3.0"
}
}
}