Skip to content

UX: show complete URL path if website domain is same as instance domain - #5

Open
ShashankFC wants to merge 1 commit into
url-handling-prefrom
url-handling-post
Open

UX: show complete URL path if website domain is same as instance domain#5
ShashankFC wants to merge 1 commit into
url-handling-prefrom
url-handling-post

Conversation

@ShashankFC

@ShashankFC ShashankFC commented Feb 4, 2026

Copy link
Copy Markdown

Test 6

Summary by CodeRabbit

  • Refactor

    • Reorganized code architecture to improve maintainability and better separate concerns.
  • Tests

    • Enhanced test coverage for website domain name handling with new test cases covering different domain matching scenarios, including host name derivation and path normalization based on domain configuration relationships.

✏️ Tip: You can customize this high-level summary in your review settings.


Replicated from ai-code-review-evaluation/discourse-coderabbit#6


EntelligenceAI PR Summary

Refactored user website name display logic from frontend computed properties to backend serialization with intelligent domain-based path inclusion.

  • Removed websiteName computed property from user controller
  • Updated Handlebars template to reference model.website_name instead of websiteName
  • Added website_name serializer attribute that extracts hostname and conditionally includes path for same-domain or subdomain websites
  • Added comprehensive test coverage for domain matching logic with three test scenarios
  • Fixed JSDoc documentation error in User model (websiteNameprofileBackground)

@entelligence-ai-pr-reviews entelligence-ai-pr-reviews Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Walkthrough

This PR refactors how user website names are displayed in the profile by moving the logic from frontend computed properties to backend serialization. The websiteName computed property is removed from the user controller, and template references are updated to use model.website_name instead. A new website_name attribute is added to the UserSerializer that intelligently extracts the hostname from the website URL and conditionally includes the path when the website domain matches or is a subdomain of the Discourse instance. Comprehensive test coverage verifies the domain matching logic, and a JSDoc documentation error is corrected in the User model.

Changes

File(s) Summary
app/assets/javascripts/discourse/controllers/user.js.es6 Removed the websiteName computed property that previously extracted domain names from user website URLs.
app/assets/javascripts/discourse/templates/user/user.hbs Refactored to use model.website_name directly instead of the websiteName computed property in three locations (conditional check and two display locations).
app/serializers/user_serializer.rb Added website_name attribute that extracts hostname from website URL and conditionally includes path when domain matches or is a subdomain of the Discourse instance hostname.
spec/serializers/user_serializer_spec.rb Added test coverage for website_name field with three test cases verifying hostname-only display, full path display for matching domains, and subdomain handling. Updated test URL to include path.
app/assets/javascripts/discourse/models/user.js.es6 Fixed JSDoc documentation error: corrected @property tag from websiteName to profileBackground.

Sequence Diagram

This diagram shows the interactions between components:

sequenceDiagram
    participant Component as Ember Component
    participant Model as Model Object
    
    Note over Component: websiteName property (REMOVED)
    
    Component->>Model: get('model.website')
    Model-->>Component: website URL string
    
    alt website is empty
        Component->>Component: return undefined
    else website has value
        Component->>Component: split("/")[2]
        Note over Component: Extract domain from URL<br/>(e.g., "http://example.com/path"<br/>→ "example.com")
        Component->>Component: return domain name
    end
    
    Note over Component: This computed property has been<br/>removed in this PR
Loading

🔗 Cross-Repository Impact Analysis

Enable automatic detection of breaking changes across your dependent repositories. → Set up now

Learn more about Cross-Repository Analysis

What It Does

  • Automatically identifies repositories that depend on this code
  • Analyzes potential breaking changes across your entire codebase
  • Provides risk assessment before merging to prevent cross-repo issues

How to Enable

  1. Visit Settings → Code Management
  2. Configure repository dependencies
  3. Future PRs will automatically include cross-repo impact analysis!

Benefits

  • 🛡️ Prevent breaking changes across repositories
  • 🔍 Catch integration issues before they reach production
  • 📊 Better visibility into your multi-repo architecture

▶️AI Code Reviews for VS Code, Cursor, Windsurf
Install the extension

Note for Windsurf Please change the default marketplace provider to the following in the windsurf settings:

Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery

Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items

Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below

Emoji Descriptions:

  • ⚠️ Potential Issue - May require further investigation.
  • 🔒 Security Vulnerability - Fix to ensure system safety.
  • 💻 Code Improvement - Suggestions to enhance code quality.
  • 🔨 Refactor Suggestion - Recommendations for restructuring code.
  • ℹ️ Others - General comments and information.

Interact with the Bot:

  • Send a message or request using the format:
    @entelligenceai + *your message*
Example: @entelligenceai Can you suggest improvements for this code?
  • Help the Bot learn by providing feedback on its responses.
    @entelligenceai + *feedback*
Example: @entelligenceai Do not comment on `save_auth` function !

Also you can trigger various commands with the bot by doing
@entelligenceai command

The current supported commands are

  1. config - shows the current config
  2. retrigger_review - retriggers the review

More commands to be added soon.

Comment on lines 40 to 46
:bio_cooked,
:created_at,
:website,
:website_name,
:profile_background,
:card_background,
:location,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Correctness: Move :website_name from the attributes list to the untrusted_attributes list. Since :website_name is derived from :website, it must be subject to the same scope.restrict_user_fields?(object) check to prevent a privacy leak where untrusted users' website information is exposed while the main :website field is restricted. Additionally, the predicate include_website_name is missing the ? suffix required by the serializer to correctly gate the attribute.

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

Successfully merging this pull request may close these issues.

2 participants