-
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
|
@claude review this PR |
1 similar comment
|
@claude review this PR |
|
Claude finished @akshayutture-augment's task —— View job PR Review Complete ✓Todo List:
SummaryThis PR refactors the website display logic from client-side (JavaScript) to server-side (Ruby), showing the complete URL path when the website domain matches the Discourse instance domain. The implementation is generally solid with good test coverage, but there are several issues that need attention. Critical Issues1. String Mutation Bug in Ruby Code 🔴Location: discourse_host.ends_with?("." << website_host)Problem: The Fix: Use string concatenation instead: discourse_host.ends_with?("." + website_host)2. Incomplete Domain Matching Logic 🟡Location: The current logic has gaps: Case 1:
Case 2: Multi-level subdomain comparison
Case 3: Parent domain check
Missing test case: What happens when 3. Inconsistent Documentation 🟡Location: The JSDoc comment for Medium Priority Issues4. Missing Error Handling 🟡Location: website_host = URI(website.to_s).host rescue nilUsing inline begin
website_host = URI(website.to_s).host
rescue URI::InvalidURIError
return nil
endThis makes the error handling explicit and only catches the expected exception type. 5. Potential Nil Safety Issue 🟡Location: website_host + URI(website.to_s).pathIf def website_name
return nil unless website.present?
begin
uri = URI(website.to_s)
website_host = uri.host
return nil if website_host.nil?
discourse_host = Discourse.current_hostname
# ... rest of logic
rescue URI::InvalidURIError
nil
end
end6. Test Coverage Gap 🟡Location: Missing test cases:
Low Priority / Style Issues7. Code Organization 🔵The def website_name
return nil unless website.present?
uri = parse_website_uri
return nil unless uri
website_host = uri.host
discourse_host = Discourse.current_hostname
should_show_full_path?(website_host, discourse_host) ?
website_host + uri.path :
website_host
end
private
def parse_website_uri
URI(website.to_s)
rescue URI::InvalidURIError
nil
end
def should_show_full_path?(website_host, discourse_host)
return true if website_host == discourse_host
return true if same_parent_domain?(website_host, discourse_host)
return true if website_is_parent_of_discourse?(website_host, discourse_host)
false
end
def same_parent_domain?(host1, host2)
parts1 = host1.split('.')
parts2 = host2.split('.')
return false unless parts1.length == parts2.length && parts1.length > 2
parts1[1..-1] == parts2[1..-1]
end
def website_is_parent_of_discourse?(website_host, discourse_host)
discourse_host.ends_with?("." + website_host)
end8. Comment Quality 🔵Location: The inline comments are helpful but could be more descriptive: # Both domains are identical, show full path
# Sibling subdomains (www.example.com vs forum.example.com), show full path if same parent
# Website domain is parent of discourse domain (example.com parent of forums.example.com)Positive Aspects ✨
RecommendationsMust Fix Before Merge:
Should Fix: Consider: Questions for Author
|
Test 6
Replicated from ai-code-review-evaluation/discourse-greptile#6