Skip to content

Commit

Permalink
fix(types): correct types for quota bytes
Browse files Browse the repository at this point in the history
As per RFC the value shall be octets representing the quota,
in all cases I know the value will be parsed to `number` by the XML parser.
(tested e.g. with Sabre / Nextcloud).

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jul 24, 2024
1 parent e409a59 commit f37a792
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion source/tools/quota.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export function parseQuota(result: DAVResult): DiskQuota | null {
} = responseItem;
return typeof quotaUsed !== "undefined" && typeof quotaAvail !== "undefined"
? {
used: parseInt(quotaUsed, 10),
// As it could be both a string or a number ensure we are working with a number
used: parseInt(String(quotaUsed), 10),
available: translateDiskSpace(quotaAvail)
}
: null;
Expand Down
4 changes: 2 additions & 2 deletions source/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export interface DAVResultResponseProps {
getetag?: string;
getcontentlength?: string;
getcontenttype?: string;
"quota-available-bytes"?: any;
"quota-used-bytes"?: string;
"quota-available-bytes"?: string | number;
"quota-used-bytes"?: string | number;

[additionalProp: string]: unknown;
}
Expand Down

0 comments on commit f37a792

Please sign in to comment.