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

[BUG] custom server URL validation fails on URLs lacking TLD #170

Open
smartin015 opened this issue Jun 23, 2022 · 1 comment
Open

[BUG] custom server URL validation fails on URLs lacking TLD #170

smartin015 opened this issue Jun 23, 2022 · 1 comment

Comments

@smartin015
Copy link
Contributor

smartin015 commented Jun 23, 2022

Describe the bug

There is a regression from previous TSD behavior where I was successfully able to configure a connection to my self-hosted Obico server with http://hostname:3334.

To Reproduce

  1. Go to octoprint instance, with fresh installation of Obico plugin
  2. Click "Custom server" radio button, type e.g. http://hostname:3334/, click Continue

Rather than continuing to the next screen, an Invalid server address error appears and the wizard cannot continue.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux
  • Browser: Chrome
  • Version: 102.0.5005.75

Additional context

The regex you're using for URL validation requires that there's a TLD after the hostname. While this is technically correct, the TLD can be left implicit when resolving hostnames on a local network. A host named host1 for instance, can be resolved with http://host1:3334, although it may sometimes be implicitly routed as e.g. http://host1.local:3334 (I'm a bit fuzzy on this - appending .local appears to work here, but IIRC windows prefers .lan... and users can set their own local network TLD. Confusing).

I recommend changing your regex to:

^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$

Which is more permissive and lacks the TLD constraint, bringing the process back to parity with pre-Obico.

@smartin015 smartin015 changed the title [BUG] custom server URL validation fails on hostname URLs [BUG] custom server URL validation fails on URLs lacking TLD Jun 23, 2022
@kennethjiang
Copy link
Contributor

Good point. Feel free to send a PR for it and I'll merge it.

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

2 participants