feross / feross/simple-get

How to figure out redirected URL?

Open
#45 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
402
Forks
49
PR merge metrics
No merged PRs in 30d

Description

Since POST doesn't follow redirects (per design, see #35), I need to be able to detect when a redirect happens and figure out the new URL, so I can re-issue my POST request.

Actually, git does a GET request before each POST request, so I can probably detect the redirect from the first GET request and infer the new correct path for the POST request before I make it. But either way, basically I need to recover the new URL after redirection is resolved.

Here's what I have so far:
```js
get('https://github.com/wmhilton/isomorphic-git', (err, res) => console.log(res.req.path))
```

That gets me the path, but I haven't figured out the best way to get the protocol/hostname/port.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.