mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
add missing null checks to R2 conversion
This commit is contained in:
parent
482b28195a
commit
13b7485b1a
@ -82,6 +82,9 @@ type R2HTTPMetadata struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func toR2HTTPMetadata(v js.Value) (R2HTTPMetadata, error) {
|
func toR2HTTPMetadata(v js.Value) (R2HTTPMetadata, error) {
|
||||||
|
if v.IsUndefined() || v.IsNull() {
|
||||||
|
return R2HTTPMetadata{}, nil
|
||||||
|
}
|
||||||
cacheExpiry, err := jsutil.MaybeDate(v.Get("cacheExpiry"))
|
cacheExpiry, err := jsutil.MaybeDate(v.Get("cacheExpiry"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return R2HTTPMetadata{}, fmt.Errorf("error converting cacheExpiry: %w", err)
|
return R2HTTPMetadata{}, fmt.Errorf("error converting cacheExpiry: %w", err)
|
||||||
|
@ -66,6 +66,9 @@ func AwaitPromise(promiseVal js.Value) (js.Value, error) {
|
|||||||
|
|
||||||
// StrRecordToMap converts JavaScript side's Record<string, string> into map[string]string.
|
// StrRecordToMap converts JavaScript side's Record<string, string> into map[string]string.
|
||||||
func StrRecordToMap(v js.Value) map[string]string {
|
func StrRecordToMap(v js.Value) map[string]string {
|
||||||
|
if v.IsUndefined() || v.IsNull() {
|
||||||
|
return map[string]string{}
|
||||||
|
}
|
||||||
entries := ObjectClass.Call("entries", v)
|
entries := ObjectClass.Call("entries", v)
|
||||||
entriesLen := entries.Get("length").Int()
|
entriesLen := entries.Get("length").Int()
|
||||||
result := make(map[string]string, entriesLen)
|
result := make(map[string]string, entriesLen)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user