MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / buildUrl

Method buildUrl

packages/filesystem/s3/client.ts:178–198  ·  view source on GitHub ↗

构建请求 URL

(bucket: string, key?: string, queryParams?: Record<string, string>)

Source from the content-addressed store, hash-verified

176
177 /** 构建请求 URL */
178 private buildUrl(bucket: string, key?: string, queryParams?: Record<string, string>): string {
179 const proto = this.parsedEndpoint.protocol;
180 const host = this.getHost(bucket);
181 let path: string;
182 if (this.config.forcePathStyle) {
183 path = `/${bucket}`;
184 if (key) path += `/${awsUriEncode(key, false)}`;
185 } else {
186 path = key ? `/${awsUriEncode(key, false)}` : "/";
187 }
188
189 let url = `${proto}//${host}${path}`;
190 if (queryParams && Object.keys(queryParams).length > 0) {
191 const qs = Object.entries(queryParams)
192 .sort(([a], [b]) => a.localeCompare(b))
193 .map(([k, v]) => `${awsUriEncode(k)}=${awsUriEncode(v)}`)
194 .join("&");
195 url += `?${qs}`;
196 }
197 return url;
198 }
199
200 /** AWS Signature V4 签名 */
201 private async signRequest(

Callers 1

requestMethod · 0.95

Calls 5

getHostMethod · 0.95
awsUriEncodeFunction · 0.85
keysMethod · 0.80
sortMethod · 0.80
entriesMethod · 0.80

Tested by

no test coverage detected