Skip to content

Trim domain to first word in server URL #693

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kanishk98
Copy link
Collaborator

If the app is unable to fetch the realm name, the server alias will now
default to first word after the protocol scheme in the server URL.


What's this PR do?

Changes serverConf object so that if the app is unable to save the correct realm name, the sidebar receives the first character of the URL after ://.

Any background context you want to provide?

Discussion at #675

Screenshots?

54884441-20dea080-4e97-11e9-9c7d-ccbf4e32d54f

You have tested this PR on:

  • Windows
  • Linux/Ubuntu
  • macOS

If the app is unable to fetch the realm name, the server alias will now
default to first word after the protocol scheme in the server URL.
@akashnimare
Copy link
Member

Would it make sense to put the trimDomain function in the new request-util.js ?

Copy link
Collaborator

@vsvipul vsvipul left a comment

Choose a reason for hiding this comment

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

The function trimDomain() works as expected. It extracts abc from https://abc.zulipchat.com or zulip from http://zulip.orgname.com. We still don't get the org name in the second case, where user accesses a self-hosted server. For rest of the cases, works fine :)

@vsvipul
Copy link
Collaborator

vsvipul commented Apr 2, 2019

Would it make sense to put the trimDomain function in the new request-util.js ?

No, it wouldn't i guess. The request-util returns header options for all requests in domain-util, and does not return alias name.

@abhigyank
Copy link
Collaborator

abhigyank commented Apr 2, 2019

There are three cases of url here :-

  • abc.domain.com - Show a
  • zulip.domain.com / server1.zulip.domain.com - Show d / show s
  • domain.com - show d (very rare case)

It is easy for us to implement for the first case as done in this case. The problem arises when we want to distinguish between first and second case which I feel is impossible for us to do. I am not sure if showing z in case of 2nd case an improvement from the the current implementation of showing the defaultIcon or is infact an increment of poor UX. Really unsure as to what the way forward should be here in this case.

@kanishk98
Copy link
Collaborator Author

kanishk98 commented Apr 2, 2019

zulip.domain.com / server1.zulip.domain.com - Show d / show s

@abhigyank correct me if I'm wrong, but the problem here is just the word zulip in the server URL, right?
If that's the case, we can check if the first word of the URL after the protocol scheme starts with zulip. If so, then we assume that the URL is of the form zulip.domain.com and show d.
The current case should show s in case of server1.zulip.domain.com, and I'm guessing that's acceptable. (If not, we can simply check for zulip and find the next immediate word that exists. Of course, we'll have to make sure we don't overrun case 1 when doing this).

@kanishk98
Copy link
Collaborator Author

Please let me know if any further changes are required here.

@abhigyank
Copy link
Collaborator

but the problem here is just the word zulip in the server URL, right?
If that's the case, we can check if the first word of the URL after the protocol scheme starts with zulip. If so, then we assume that the URL is of the form zulip.domain.com and show d.

I don't want us to hard-code here (I am never in favour of hard-coding anything! 😅 ) The reason being we don't want to assume that its always zulip in such a subdomain. I am not sure what is the right way to go here. 😕

@kanishk98
Copy link
Collaborator Author

kanishk98 commented Apr 4, 2019 via email

@kanishk98
Copy link
Collaborator Author

@rishig would you mind having a look at this whenever you're free and telling us what you think?

@rishig
Copy link
Member

rishig commented Apr 13, 2019

I think we should just show some kind of error state if the realm doesn't have an avatar set (e.g. a box with a ?).

@kanishk98
Copy link
Collaborator Author

I think we should just show some kind of error state if the realm doesn't have an avatar set (e.g. a box with a ?).

I think that'll be a good solution when we don't have this kind of behaviour come up frequently (which is the case right now). When @akashnimare is able to find time to review #714 and we cut down on the number of times this fallback icon needs to be used, we can use the ?. Sound good?

@zulipbot
Copy link
Member

Heads up @kanishk98, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/master branch and resolve your pull request's merge conflicts accordingly.

Base automatically changed from master to main January 22, 2021 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants