Skip to content

Commit

Permalink
Merge pull request #794 from nextcloud-libraries/feat/encodedSource
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv committed Oct 3, 2023
2 parents f02fb42 + 6655f2e commit a8a2910
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/files/node.ts
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
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"
}
}
}

0 comments on commit a8a2910

Please sign in to comment.