Skip to content

Commit 181830e

Browse files
committed
refactor: simplify method handling
1 parent 14b6b39 commit 181830e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/main.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,11 @@ export class Blobs {
6767
}
6868

6969
private async getFinalRequest(key: string, method: string) {
70-
const finalMethod = method
71-
7270
if ('contextURL' in this.authentication) {
7371
return {
7472
headers: {
7573
authorization: `Bearer ${this.authentication.token}`,
7674
},
77-
method: finalMethod,
7875
url: `${this.authentication.contextURL}/${this.siteID}/${this.context}/${key}`,
7976
}
8077
}
@@ -90,7 +87,6 @@ export class Blobs {
9087
const { url } = await res.json()
9188

9289
return {
93-
method: finalMethod,
9490
url,
9591
}
9692
}
@@ -129,7 +125,7 @@ export class Blobs {
129125
throw new Error("The blob store is unavailable because it's missing required configuration properties")
130126
}
131127

132-
const { headers: baseHeaders = {}, method: finalMethod, url } = await this.getFinalRequest(key, method)
128+
const { headers: baseHeaders = {}, url } = await this.getFinalRequest(key, method)
133129
const headers: Record<string, string> = {
134130
...baseHeaders,
135131
...extraHeaders,
@@ -139,9 +135,9 @@ export class Blobs {
139135
headers['cache-control'] = 'max-age=0, stale-while-revalidate=60'
140136
}
141137

142-
const res = await this.fetcher(url, { body, headers, method: finalMethod })
138+
const res = await this.fetcher(url, { body, headers, method })
143139

144-
if (res.status === 404 && finalMethod === HTTPMethod.Get) {
140+
if (res.status === 404 && method === HTTPMethod.Get) {
145141
return null
146142
}
147143

0 commit comments

Comments
 (0)