Skip to content

Commit

Permalink
fix: 🩹 remove leading '&' from URL parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnsilva committed Dec 1, 2023
1 parent 805a985 commit 97ac08c
Show file tree
Hide file tree
Showing 30 changed files with 346,638 additions and 317,821 deletions.
2 changes: 1 addition & 1 deletion semanticscholar/ApiRequester.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def get_data_async(
:rtype: :class:`dict` or :class:`List` of :class:`dict`
'''

url = f'{url}?{parameters}'
url = f'{url}?{parameters.lstrip("&")}'
method = 'POST' if payload else 'GET'

async with httpx.AsyncClient() as client:
Expand Down
108 changes: 54 additions & 54 deletions tests/data/test_bad_query_parameters.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
interactions:
- request:
body: ''
headers:
accept:
- '*/*'
accept-encoding:
- gzip, deflate
connection:
- keep-alive
host:
- api.semanticscholar.org
user-agent:
- python-httpx/0.24.1
method: GET
uri: https://api.semanticscholar.org/graph/v1/paper/10.1093/mind/lix.236.433?&fields=unknown
response:
content: '{"error":"Unrecognized or unsupported fields: [unknown]"}
'
headers:
Access-Control-Allow-Origin:
- '*'
Connection:
- keep-alive
Content-Length:
- '58'
Content-Type:
- application/json
Date:
- Wed, 13 Sep 2023 21:45:56 GMT
Via:
- 1.1 b6217766ccd41d69658fea04297b7c24.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- e98Cj3bmP0ZHX6Rnclk_otvw6ewcsdlwsG8n39gdGfJRnQzxR4mtkA==
X-Amz-Cf-Pop:
- EWR50-C1
X-Cache:
- Error from cloudfront
x-amz-apigw-id:
- LNwPSGY9PHcFsFA=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '58'
x-amzn-Remapped-Date:
- Wed, 13 Sep 2023 21:45:56 GMT
x-amzn-Remapped-Server:
- gunicorn
x-amzn-RequestId:
- 8b2f928e-25d9-4784-a3b5-375ae7ba5641
http_version: HTTP/1.1
status_code: 400
version: 1
interactions:
- request:
body: ''
headers:
accept:
- '*/*'
accept-encoding:
- gzip, deflate
connection:
- keep-alive
host:
- api.semanticscholar.org
user-agent:
- python-httpx/0.25.1
method: GET
uri: https://api.semanticscholar.org/graph/v1/paper/10.1093/mind/lix.236.433?fields=unknown
response:
content: '{"error":"Unrecognized or unsupported fields: [unknown]"}
'
headers:
Access-Control-Allow-Origin:
- '*'
Connection:
- keep-alive
Content-Length:
- '58'
Content-Type:
- application/json
Date:
- Fri, 01 Dec 2023 02:36:24 GMT
Via:
- 1.1 97d891785cd24c4beaf3832c02f5cf04.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- 6zc4NIMW_Pv1Wt0rCO95424W0VyiM0qGTbAiAMncLi2vbDWu5L8dIw==
X-Amz-Cf-Pop:
- GRU3-P4
X-Cache:
- Error from cloudfront
x-amz-apigw-id:
- PPf6YHCPvHcEsig=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '58'
x-amzn-Remapped-Date:
- Fri, 01 Dec 2023 02:36:24 GMT
x-amzn-Remapped-Server:
- gunicorn
x-amzn-RequestId:
- b6d40e26-c245-49b0-a102-95e016226035
http_version: HTTP/1.1
status_code: 400
version: 1
14 changes: 7 additions & 7 deletions tests/data/test_bad_query_parameters_async.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interactions:
user-agent:
- python-httpx/0.25.1
method: GET
uri: https://api.semanticscholar.org/graph/v1/paper/10.1093/mind/lix.236.433?&fields=unknown
uri: https://api.semanticscholar.org/graph/v1/paper/10.1093/mind/lix.236.433?fields=unknown
response:
content: '{"error":"Unrecognized or unsupported fields: [unknown]"}
Expand All @@ -28,27 +28,27 @@ interactions:
Content-Type:
- application/json
Date:
- Tue, 21 Nov 2023 04:20:57 GMT
- Fri, 01 Dec 2023 02:19:29 GMT
Via:
- 1.1 5bfc01a743251c97602fd0fa441f1900.cloudfront.net (CloudFront)
- 1.1 0e3b340d2469d5d03795669e20d22b7e.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- BShH38ZD6tu-Tk_o5CglgKaFNmHW-EUyHDy88v8CA7YTHOX0SlFNCg==
- gLmDEcgK66PKBL1iF22GE69v5Rm91jeLPvU1JVE656FyuC6BGtinQA==
X-Amz-Cf-Pop:
- GRU3-P4
X-Cache:
- Error from cloudfront
x-amz-apigw-id:
- Oux2mEdovHcEBgw=
- PPdbsFOXvHcEWPw=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '58'
x-amzn-Remapped-Date:
- Tue, 21 Nov 2023 04:20:57 GMT
- Fri, 01 Dec 2023 02:19:29 GMT
x-amzn-Remapped-Server:
- gunicorn
x-amzn-RequestId:
- 69b07d73-7eef-4674-af2f-853d1461c567
- 3bb79121-8f5d-4786-870d-689544a55729
http_version: HTTP/1.1
status_code: 400
version: 1

0 comments on commit 97ac08c

Please sign in to comment.