I think there's no need to replace `%20` since you're calling `encodeURIComponent` both on `name` and `value` earlier?