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

API Endpoint doesn't check for trailing slash #9

Closed
WhoSoup opened this issue Sep 16, 2019 · 2 comments
Closed

API Endpoint doesn't check for trailing slash #9

WhoSoup opened this issue Sep 16, 2019 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@WhoSoup
Copy link
Contributor

WhoSoup commented Sep 16, 2019

Client.FactomdRequest/WalletdRequest just tacks on "/v2" without checking to see if the provided url already has a trailing slash.

This works:

	cli := &factom.Client{FactomdServer: "https://api.factomd.net"}
	h := new(factom.Heights)
	fmt.Println(h.Get(cli))

This doesn't work:

	cli := &factom.Client{FactomdServer: "https://api.factomd.net/"}
	h := new(factom.Heights)
	fmt.Println(h.Get(cli))
@AdamSLevy
Copy link
Collaborator

AdamSLevy commented Sep 17, 2019

The proper way to handle this would be to use net/url and call url.Parse() and check for the URL{}.Path string.

On the other hand, we could omit appending the "v2" string all together. Which I like better actually. This requires the user of this package to know the exact URL.

For applications where the user shouldn't have to be more strict, the above approach can be taken before passing the url strings to this package.

@AdamSLevy AdamSLevy added bug Something isn't working good first issue Good for newcomers labels Sep 17, 2019
@AdamSLevy AdamSLevy added this to the v1 milestone Sep 17, 2019
@AdamSLevy
Copy link
Collaborator

It is now entirely up to client to have the request URL correct. The trailing /v2 is no longer appended and clients must add this path to their URLs if needed for the servers they are connecting to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants