Pythe1337N / garmin-connect

Makes it simple to interface with Garmin Connect to get or set any data point.
MIT License
145 stars 59 forks source link

Remove required quotes in content-disposition header #35

Closed CDillinger closed 2 years ago

CDillinger commented 2 years ago

When trying to download a TCX file, I was facing errors like this:

(node:4767) UnhandledPromiseRejectionWarning: TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))

and the stack trace pointed to this line.

I logged the response here and found this header did not include quotes for the activities from my account. Example observed header value:

'content-disposition': 'attachment; filename=activity_8627651372.tcx'

I removed the quotes on this line and the TCX download began working as expected.

Thank you for creating this library!

Pythe1337N commented 2 years ago

Comment says Will default to 'zip'. Other possible values are 'tcx', 'gpx' or 'kml'. Can you just give it a try for all file types and then i can do the merge. Just want to make sure it's the same for every case. Otherwise we need to support both. I guess changing the regex to filename="?([^"]+)"? would cover both cases in one go.

CDillinger commented 2 years ago

zip is indeed broken on my changes, but all the other formats work:

Screen Shot 2022-04-14 at 6 51 30 PM
CDillinger commented 2 years ago

Your proposed regex works as expected for all formats:

Screen Shot 2022-04-14 at 6 54 04 PM

I will update the PR. Thank you!