use explicit protocol when replacing links in documents from proxies #1358
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a change to how links are rewritten when proxying a site that serves responses on both "http" and "https" protocols but does not necessarily have functional consistency between the two. Specifically, all URL's that the proxy rewrites would include the protocol, rather than being protocol-relative. That is, they would start with "http://" or "https://" rather than "//". Rewritten links would always have the same protocol as the proxy target. This is mainly to solve an issue that I'm facing in the case of a proxied site has an inline script where it puts its full origin in a variable, which is subsequently used to construct API endpoints by JS functions whose parsing logic expects the URL in that variable to have an explicit protocol. In general, I suggest that explicit protocols in rewritten links is a functional improvement for the browser-sync proxy, because it avoids conflating protocols when proxying targets that are part of a dual-protocol site with protocol-specific functionality.