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

[core-http] support username and password in proxy url string #7211

Merged
merged 3 commits into from
Feb 11, 2020

Conversation

jeremymeng
Copy link
Member

by extracting then removing them from the url and parse the updated
url as URLBuilder doesn't support them.

For #5011

@jeremymeng
Copy link
Member Author

This is an alternative to PR #7168

@jeremymeng jeremymeng added Azure.Core Client This issue points to a problem in the data-plane of the library. labels Feb 3, 2020
Copy link
Member

@xirzec xirzec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable. Thanks for the tests.

by extracting then removing them from the url and parse the updated
url as URLBuilder doesn't support them.
return { urlWithoutAuth: url};
}

const schemeIndex = url.indexOf("://")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you could get away with using a regex to simplify the parsing here:

const urlMatch = url.match(/((\w+):\/\/)?((.*):(.*)@)?.*$/);
const username = urlMatch[4];
const password = urlMatch[5];

Not sure if it's more likely to cause trouble than the current approach though, so take it or leave it :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! It is more JavaScript-y. Although I also need to remove the auth part from the original url. I'd need another regex to do that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants