Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyperlink address in response includes trailing double quote (version 0.24.5) #816

Closed
thofil73 opened this issue Apr 12, 2021 · 9 comments
Closed

Comments

@thofil73
Copy link

My JSON response contains download links for files like
{
...
"url": "https://path/to/file.ext"
}

RestClient v0.24.5 creates a hyperlink from it with the following target address:
https://path/to/file.ext"
When I click the hyperlink, it won't resolve because of the trailing double quote added by RestClient.

In v0.24.4 this worked fine. RestClient created target address as expected:
https://path/to/file.ext

@adibradfield
Copy link
Contributor

adibradfield commented Apr 13, 2021

I have just had to come off quite an embarrassing call with a supplier where I said that the URLs that their API was generating weren't working properly. It was actually this issue 😂

@adibradfield
Copy link
Contributor

If it helps in finding what caused this bug, I first reported the "issue" to the supplier on the 8th April, so the bug was released either then or the day before

@asmith3006
Copy link

I just spent 5 minutes making a screenshot to demonstrate this issue!

I'm getting the same thing:

VSCode 1.55.2
Restclient: 0.24.5

@asmith3006
Copy link

asmith3006 commented May 13, 2021

Quick workaround:
image

And select 0.24.4

Then this problem is not present.

@adibradfield
Copy link
Contributor

adibradfield commented May 20, 2021

This has been bugging me so decided to look into it. Looks like the update to the highlight.js dependency is the culprit. There is a PR there which HTML encodes quote characters to " highlightjs/highlight.js#2235.

This has then broken the regex that is used to detect URLs in the addUrlLinks method in src/views/httpResponseWebview.ts since there isn't actually a quote mark in the string anymore.

The simplest fix would be to just roll the version back, but it was probably upgraded for a reason.

I don't think it will be possible to fix the regex to not include " in the match, without also breaking query parameters

Possibly could get it to work by updating it to use a replacer function instead, which could decode the match, select non URL characters from the end of the match, strip them from the anchor href and text, then add them back in outside the anchor.

I'll see if I can get a PR together at some point soon

@adibradfield
Copy link
Contributor

Just opened PR #852

@Huachao Huachao closed this as completed Nov 29, 2021
@Huachao
Copy link
Owner

Huachao commented Nov 29, 2021

@asmith3006 @adibradfield @thofil73 @nasypovd @SawatzkiWestfalia @johnnytemp this has been fixed in the lastest verison 0.24.6 and you can have a try, thanks @adibradfield's help

@thofil73
Copy link
Author

thofil73 commented Nov 29, 2021 via email

@asmith3006
Copy link

Tested here too, thank you!!!! @Huachao love your work and thank you @adibradfield for sorting this particular issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants