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

Added regex to handle url parts #603

Merged
merged 8 commits into from
Feb 26, 2020
Merged

Added regex to handle url parts #603

merged 8 commits into from
Feb 26, 2020

Conversation

JacobAnavisca
Copy link
Contributor

@JacobAnavisca JacobAnavisca commented Feb 25, 2020

Fix #62
Fix #581

@ghost
Copy link

ghost commented Feb 25, 2020

Congratulations 🍻. DeepCode analyzed your code in 0.618 seconds and we found no issues. Enjoy a moment of no bugs ☀️.

💬 This comment has been generated by the DeepCode bot, installed by the owner of the repository. The DeepCode bot protects your repository by detecting and commenting on security vulnerabilities or other critical issues.


☺️ If you want to provide feedback on our bot, here is how to contact us.

@TravisBuddy
Copy link

Hey @JacobAnavisca,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: c3615f20-579a-11ea-acab-ef795e2c3319

@TravisBuddy
Copy link

Hey @JacobAnavisca,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: bc2c0e60-579c-11ea-acab-ef795e2c3319

@liyasthomas
Copy link
Member

@JacobAnavisca there seems to be a problem with parsing URL while passing URL via parameter. That's why tests are failing. I suggest you to run npm run dev:e2e for testing few use cases.

@liyasthomas
Copy link
Member

liyasthomas commented Feb 25, 2020

@JacobAnavisca pre-commit hooks have been introduced hence please rebase to current master and pull latest change, then send PR. run npm run build and npm run test to verify PR pass test cases.

@TravisBuddy
Copy link

Hey @JacobAnavisca,
Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: f1a14720-57e4-11ea-acab-ef795e2c3319

@NBTX
Copy link
Contributor

NBTX commented Feb 25, 2020

I don't think we should be using (our own) regex for this. JavaScript has a very mature URL API:
https://developer.mozilla.org/en-US/docs/Web/API/URL

@JacobAnavisca
Copy link
Contributor Author

JacobAnavisca commented Feb 25, 2020

main reason I'm using regex is to handle environment variables, like << baseUrl >>/get

@NBTX
Copy link
Contributor

NBTX commented Feb 26, 2020

Could we substitute them before we try parsing?

@JacobAnavisca
Copy link
Contributor Author

How about regex as a fallback? like so:
uri: { get() { return this.$store.state.request.uri ? this.$store.state.request.uri : this.url + this.path; }, set(value) { this.$store.commit("setState", { value, attribute: "uri" }) let url; if (this.preRequestScript && this.showPreRequestScript) { const environmentVariables = getEnvironmentVariablesFromScript(this.preRequestScript); url = parseTemplateString(value, environmentVariables); } try { url = new URL(url); this.url = url.origin; this.path = url.pathname; } catch(error) { console.log(error) let uriRegex = value.match( /^((http[s]?:\/\/)?(<<[^\/]+>>)?[^\/]*|)(\/?.*)$/ ); this.url = uriRegex[1]; this.path = uriRegex[4]; } } }

@TravisBuddy
Copy link

Hey @JacobAnavisca,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: adcf5c10-584f-11ea-b533-891a36a4ac0b

@TravisBuddy
Copy link

Hey @JacobAnavisca,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 851805f0-5855-11ea-b533-891a36a4ac0b

@hoppscotch hoppscotch deleted a comment from TravisBuddy Feb 26, 2020
@TravisBuddy
Copy link

Hey @JacobAnavisca,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 228e7830-5858-11ea-b533-891a36a4ac0b

@liyasthomas liyasthomas removed the do not merge This will break everything label Feb 26, 2020
@TravisBuddy
Copy link

Hey @JacobAnavisca,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 7c375050-5871-11ea-b533-891a36a4ac0b

Copy link
Member

@liyasthomas liyasthomas left a comment

Choose a reason for hiding this comment

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

LGTM

@liyasthomas liyasthomas self-assigned this Feb 26, 2020
@liyasthomas liyasthomas merged commit 679ef22 into master Feb 26, 2020
@liyasthomas liyasthomas deleted the feature/fast-url branch February 26, 2020 17:03
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

Successfully merging this pull request may close these issues.

Bigger URL and/or Path input field Fast URL entry
4 participants