Skip to content

Commit

Permalink
Merge pull request #378 from susnux/fix/props
Browse files Browse the repository at this point in the history
fix(types): correct types for quota bytes
  • Loading branch information
perry-mitchell authored Aug 2, 2024
2 parents e48fa0f + 8844a38 commit 16f1475
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions source/tools/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export function parseSearch(result: DAVResult, searchArbiter: string, isDetailed
* @returns The value in bytes, or another indicator
*/
export function translateDiskSpace(value: string | number): DiskQuotaAvailable {
switch (value.toString()) {
switch (String(value)) {
case "-3":
return "unlimited";
case "-2":
Expand All @@ -246,6 +246,6 @@ export function translateDiskSpace(value: string | number): DiskQuotaAvailable {
// -1 is non-computed
return "unknown";
default:
return parseInt(value as string, 10);
return parseInt(String(value), 10);
}
}
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 16f1475

Please sign in to comment.