-
Notifications
You must be signed in to change notification settings - Fork 0
UX: show complete URL path if website domain is same as instance domain #5
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
base: url-handling-pre
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 3/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Browser
participant Template as user.hbs
participant Controller as UserController
participant Serializer as UserSerializer
participant Discourse as Discourse.current_hostname
Browser->>Template: Request user profile page
Template->>Controller: Access model.website_name
Note over Controller: Removed websiteName<br/>computed property
Controller->>Serializer: Fetch user data via API
Serializer->>Serializer: Call website() method
Serializer->>Serializer: Call website_name() method
Serializer->>Discourse: Get current_hostname()
Discourse-->>Serializer: Return instance hostname
Serializer->>Serializer: Parse website URL with URI()
Serializer->>Serializer: Compare website_host vs discourse_host
alt Exact match (example.com == example.com)
Serializer->>Serializer: Return host + path
else Subdomain match (www.example.com vs forum.example.com)
Serializer->>Serializer: Compare base domains
alt Base domains match
Serializer->>Serializer: Return host + path
else Base domains differ
Serializer->>Serializer: Return host only
end
else Parent domain check
Serializer->>Serializer: Check if discourse ends with website
alt Discourse is subdomain of website
Serializer->>Serializer: Return host + path
else Different domains
Serializer->>Serializer: Return host only
end
end
Serializer-->>Controller: Return serialized user with website_name
Controller-->>Template: Provide model data
Template-->>Browser: Render website link with website_name
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
| website_host.split('.')[1..-1].join('.') == discourse_host.split('.')[1..-1].join('.') ? website_host + URI(website.to_s).path : website_host | ||
| else | ||
| # example.com == forum.example.com | ||
| discourse_host.ends_with?("." << website_host) ? website_host + URI(website.to_s).path : website_host |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: String concatenation mutates discourse_host with << operator, which could cause side effects if discourse_host is reused
| discourse_host.ends_with?("." << website_host) ? website_host + URI(website.to_s).path : website_host | |
| discourse_host.ends_with?("." + website_host) ? website_host + URI(website.to_s).path : website_host |
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/serializers/user_serializer.rb
Line: 149:149
Comment:
**logic:** String concatenation mutates `discourse_host` with `<<` operator, which could cause side effects if `discourse_host` is reused
```suggestion
discourse_host.ends_with?("." + website_host) ? website_host + URI(website.to_s).path : website_host
```
How can I resolve this? If you propose a fix, please make it concise.
Test 6
Replicated from ai-code-review-evaluation/discourse-greptile#6