wangzhibo
2026-05-09 53418655c061ac26f66058253f39200aced1ab1d
1
2
3
4
5
6
7
{
  "version": 3,
  "sources": ["../../src/apiVersionPolicy.ts"],
  "sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport type { ClientOptions } from \"./common.js\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n  return {\n    name: apiVersionPolicyName,\n    sendRequest: (req, next) => {\n      // Use the apiVesion defined in request url directly\n      // Append one if there is no apiVesion and we have one at client options\n      const url = new URL(req.url);\n      if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n        req.url = `${req.url}${\n          Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n        }api-version=${options.apiVersion}`;\n      }\n\n      return next(req);\n    },\n  };\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,MAAM,uBAAuB;AAO7B,SAAS,iBAAiB,SAAwC;AACvE,SAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa,CAAC,KAAK,SAAS;AAG1B,YAAM,MAAM,IAAI,IAAI,IAAI,GAAG;AAC3B,UAAI,CAAC,IAAI,aAAa,IAAI,aAAa,KAAK,QAAQ,YAAY;AAC9D,YAAI,MAAM,GAAG,IAAI,GAAG,GAClB,MAAM,KAAK,IAAI,aAAa,KAAK,CAAC,EAAE,SAAS,IAAI,MAAM,GACzD,eAAe,QAAQ,UAAU;AAAA,MACnC;AAEA,aAAO,KAAK,GAAG;AAAA,IACjB;AAAA,EACF;AACF;",
  "names": []
}