Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(files): add encodedSource #794

Merged
merged 1 commit into from Oct 3, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
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))

Check warning on line 92 in lib/files/node.ts

View check run for this annotation

Codecov / codecov/patch

lib/files/node.ts#L91-L92

Added lines #L91 - L92 were not covered by tests
}

/**
* 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"
}
}
}