Skip to content

[654] feat(testimonials): Show only domain in testimonial links - #192

Merged
Anton-88 merged 9 commits into
mainfrom
654-feat/testimonials-show-domain-only
Jul 3, 2025
Merged

[654] feat(testimonials): Show only domain in testimonial links#192
Anton-88 merged 9 commits into
mainfrom
654-feat/testimonials-show-domain-only

Conversation

@VitalyyP

@VitalyyP VitalyyP commented Jul 2, 2025

Copy link
Copy Markdown
Contributor
  • Show only the domain part of the testimonial URL in the carousel
  • Keep the full URL as the link target

@VitalyyP
VitalyyP requested a review from killev as a code owner July 2, 2025 10:18
@coderabbitai

coderabbitai Bot commented Jul 2, 2025

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The testimonial carousel widget's template was updated to display only the domain name of a testimonial's URL as the anchor text, removing protocol, path, query, fragment, and "www." prefix. The anchor tag now always renders if card.url exists and includes a rel="noopener noreferrer" attribute.

Changes

File Change Summary
website/modules/testimonials-carousel-widget/views/widget.html Changed URL anchor text to domain-only (stripping protocol, path, query, fragment, "www.") and added rel="noopener noreferrer" attribute.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WidgetTemplate

    User ->> WidgetTemplate: Render testimonial card
    WidgetTemplate ->> WidgetTemplate: Check if card.url exists
    alt card.url exists
        WidgetTemplate ->> WidgetTemplate: Extract domain from card.url (remove protocol, path, query, fragment, "www.")
        WidgetTemplate ->> User: Display anchor with domain as text
    else card.url does not exist
        WidgetTemplate ->> User: Do not render anchor
    end
Loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
website/modules/testimonials-carousel-widget/views/widget.html (2)

41-46: Domain-extraction logic is brittle

Parsing with chained split() works only for URLs that always include a scheme (://).
//example.com (protocol-relative) or plain example.com will fail and fall back to the full URL.
Consider a tiny helper filter (e.g. url_domain) that internally uses urllib.parse.urlsplit so edge cases like ports, credentials, or missing scheme are handled robustly.


44-45: Add rel="noopener noreferrer" for external links

All links that open in a new tab should set rel="noopener noreferrer" to avoid the window.opener security issue.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc0674 and 46c164a.

📒 Files selected for processing (1)
  • website/modules/testimonials-carousel-widget/views/widget.html (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: yuramax
PR: speedandfunction/website#120
File: website/modules/asset/ui/src/index.js:43-67
Timestamp: 2025-05-26T06:19:32.209Z
Learning: When reviewing PRs focused on styling, defer functional JavaScript improvements to separate tasks to maintain clear scope separation.
Learnt from: yuramax
PR: speedandfunction/website#139
File: website/jest.config.cjs:4-4
Timestamp: 2025-06-03T16:27:46.172Z
Learning: When reviewing PRs, focus suggestions on the main objectives stated in the PR description. Skip suggestions for incidental changes that are unrelated to the PR's primary purpose, especially when the user explicitly requests to stay focused on the main feature/improvement.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: security-scan
  • GitHub Check: e2e-tests

Comment thread website/modules/testimonials-carousel-widget/views/widget.html Outdated
@github-actions

github-actions Bot commented Jul 2, 2025

Copy link
Copy Markdown

🔍 Vulnerabilities of apostrophe-cms:test

📦 Image Reference apostrophe-cms:test
digestsha256:f7d6731243ae85491c7a8e95c138cc72cf4b34d50b2678c23455a20763eb658c
vulnerabilitiescritical: 0 high: 3 medium: 0 low: 0
platformlinux/amd64
size290 MB
packages977
📦 Base Image node:23-alpine
also known as
  • 23-alpine3.22
  • 23.11-alpine
  • 23.11-alpine3.22
  • 23.11.1-alpine
  • 23.11.1-alpine3.22
digestsha256:b9d38d589853406ff0d4364f21969840c3e0397087643aef8eede40edbb6c7cd
vulnerabilitiescritical: 0 high: 0 medium: 1 low: 1
critical: 0 high: 1 medium: 0 low: 0 async 1.5.2 (npm)

pkg:npm/async@1.5.2

high 7.8: CVE--2021--43138 OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities

Affected range<2.6.4
Fixed version2.6.4, 3.2.2
CVSS Score7.8
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score0.419%
EPSS Percentile61st percentile
Description

A vulnerability exists in Async through 3.2.1 (fixed in 3.2.2), which could let a malicious user obtain privileges via the mapValues() method.

critical: 0 high: 1 medium: 0 low: 0 async 0.9.2 (npm)

pkg:npm/async@0.9.2

high 7.8: CVE--2021--43138 OWASP Top Ten 2017 Category A9 - Using Components with Known Vulnerabilities

Affected range<2.6.4
Fixed version2.6.4, 3.2.2
CVSS Score7.8
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score0.419%
EPSS Percentile61st percentile
Description

A vulnerability exists in Async through 3.2.1 (fixed in 3.2.2), which could let a malicious user obtain privileges via the mapValues() method.

critical: 0 high: 1 medium: 0 low: 0 connect-multiparty 2.2.0 (npm)

pkg:npm/connect-multiparty@2.2.0

high 7.8: CVE--2022--29623 Unrestricted Upload of File with Dangerous Type

Affected range<=2.2.0
Fixed versionNot Fixed
CVSS Score7.8
CVSS VectorCVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS Score0.334%
EPSS Percentile56th percentile
Description

An arbitrary file upload vulnerability in the file upload module of Express Connect-Multiparty 2.2.0 allows attackers to execute arbitrary code via a crafted PDF file. NOTE: the Supplier has not verified this vulnerability report.

…s, show domain only, add rel noopener noreferrer

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
website/modules/testimonials-carousel-widget/views/widget.html (2)

41-43: Make URL parsing more robust and easier to read

The chain of string splits relies on the URL containing :// and at least one / after the domain.
Edge-cases such as http://localhost:3000, query-only URLs, mailto: links, or already-trimmed domains will break or yield surprising results.

Consider centralising the logic in a small filter/helper instead of inline string gymnastics:

-{% set domain = card.url.split('://')|length > 1 and
-    card.url.split('://')[1].split('/')[0] or card.url %}
+{# utils.njk #}
+{% macro domain(url) %}
+  {%- set parts = url.split('://') -%}
+  {%- set host = (parts|length > 1 and parts[1] or parts[0]).split('/')[0] -%}
+  {{ host }}
+{% endmacro %}
+
+{# usage #}
+{% set domain = domain(card.url) %}

Benefits:
• Handles scheme-less, mailto:, or localhost URLs safely.
• Reduces template noise & duplication.
• Improves maintainability if parsing rules change.


44-48: Add rel="nofollow" and aria-label for SEO & accessibility

Since these links point to external sites beyond editorial control, adding rel="nofollow" prevents unintended SEO dilution.
An explicit aria-label (e.g., company domain) makes the link comprehensible to screen-reader users when the anchor text is just the bare domain.

-<a
-  href="{{ card.url }}"
-  target="_blank"
-  class="sf-person__url"
-  rel="noopener noreferrer"
->
+<a
+  href="{{ card.url }}"
+  target="_blank"
+  class="sf-person__url"
+  rel="noopener noreferrer nofollow"
+  aria-label="Open {{ domain }} in new tab"
+>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46c164a and e705528.

📒 Files selected for processing (1)
  • website/modules/testimonials-carousel-widget/views/widget.html (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: yuramax
PR: speedandfunction/website#120
File: website/modules/asset/ui/src/index.js:43-67
Timestamp: 2025-05-26T06:19:32.209Z
Learning: When reviewing PRs focused on styling, defer functional JavaScript improvements to separate tasks to maintain clear scope separation.
Learnt from: yuramax
PR: speedandfunction/website#139
File: website/jest.config.cjs:4-4
Timestamp: 2025-06-03T16:27:46.172Z
Learning: When reviewing PRs, focus suggestions on the main objectives stated in the PR description. Skip suggestions for incidental changes that are unrelated to the PR's primary purpose, especially when the user explicitly requests to stay focused on the main feature/improvement.
🪛 HTMLHint (1.5.0)
website/modules/testimonials-carousel-widget/views/widget.html

[error] 42-42: Special characters must be escaped : [ > ].

(spec-char-escape)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
website/modules/testimonials-carousel-widget/views/widget.html (1)

41-52: Previous invalid-markup issue fixed — good catch

Wrapping the anchor in {% if card.url %} eliminates empty <a> elements flagged in earlier reviews.
Implementation now conditionally renders and adds rel="noopener noreferrer", aligning with security best practices.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 2, 2025
@VitalyyP VitalyyP changed the title feat(testimonials): Show only domain in testimonial links [654] feat(testimonials): Show only domain in testimonial links Jul 2, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
website/modules/testimonials-carousel-widget/views/widget.html (2)

45-47: Refactor domain-extraction for robustness & readability

The current one-liner repeats split('://') twice and relies on the brittle “and … or …” idiom.
Edge-cases it misses:

• protocol-less URLs (“example.com/foo”)
• URLs containing credentials or query params
• inline > character triggers HTMLHint (spec-char-escape) because the comparison operator sits unescaped in the markup.

A small refactor makes the intent clearer, avoids repeated work, and silences the linter:

-{% set domain =
-    card.url.split('://')|length > 1 and
-    card.url.split('://')[1].split('/')[0] or card.url %}
+{# Normalise and extract the host part once #}
+{% set urlParts   = card.url.split('://') %}
+{% set remainder  = urlParts|length > 1 ? urlParts[1] : urlParts[0] %}
+{% set domain     = remainder.split('/')[0] %}

No behavioural change, but easier to reason about and HTMLHint-clean.


48-55: Consider adding rel="nofollow" to external testimonial links

noopener noreferrer is great, but search crawlers may interpret these dynamically-rendered testimonial links as paid endorsements.
Adding nofollow (or ugc) keeps SEO signals explicit:

-  rel="noopener noreferrer"
+  rel="noopener noreferrer nofollow"

Purely advisory—feel free to skip if your SEO policy differs.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e705528 and d85d53d.

📒 Files selected for processing (1)
  • website/modules/testimonials-carousel-widget/views/widget.html (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: yuramax
PR: speedandfunction/website#120
File: website/modules/asset/ui/src/index.js:43-67
Timestamp: 2025-05-26T06:19:32.209Z
Learning: When reviewing PRs focused on styling, defer functional JavaScript improvements to separate tasks to maintain clear scope separation.
Learnt from: yuramax
PR: speedandfunction/website#139
File: website/jest.config.cjs:4-4
Timestamp: 2025-06-03T16:27:46.172Z
Learning: When reviewing PRs, focus suggestions on the main objectives stated in the PR description. Skip suggestions for incidental changes that are unrelated to the PR's primary purpose, especially when the user explicitly requests to stay focused on the main feature/improvement.
🪛 HTMLHint (1.5.0)
website/modules/testimonials-carousel-widget/views/widget.html

[error] 46-46: Special characters must be escaped : [ > ].

(spec-char-escape)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: unit-tests
  • GitHub Check: lint
  • GitHub Check: e2e-tests
  • GitHub Check: security-scan

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
website/modules/testimonials-carousel-widget/views/widget.html (1)

53-60: Add graceful fallback & accessibility text for the anchor.

  1. cleanDomain could be empty when card.url is malformed.
  2. Screen-reader users don’t get any hint what the link points to.
-  <a
-    href="{{ card.url }}"
-    target="_blank"
-    class="sf-person__url"
-    rel="noopener noreferrer"
-  >
-    {{ cleanDomain }}
-  </a>
+  {% set anchorText = cleanDomain or card.url %}
+  <a
+    href="{{ card.url }}"
+    target="_blank"
+    class="sf-person__url"
+    rel="noopener noreferrer"
+    aria-label="Open {{ anchorText }} in a new tab"
+    title="{{ anchorText }}"
+  >
+    {{ anchorText }}
+  </a>

This prevents blank anchor text and improves a11y without changing visual
appearance.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d85d53d and 335b326.

📒 Files selected for processing (1)
  • website/modules/testimonials-carousel-widget/views/widget.html (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: yuramax
PR: speedandfunction/website#120
File: website/modules/asset/ui/src/index.js:43-67
Timestamp: 2025-05-26T06:19:32.209Z
Learning: When reviewing PRs focused on styling, defer functional JavaScript improvements to separate tasks to maintain clear scope separation.
Learnt from: yuramax
PR: speedandfunction/website#139
File: website/jest.config.cjs:4-4
Timestamp: 2025-06-03T16:27:46.172Z
Learning: When reviewing PRs, focus suggestions on the main objectives stated in the PR description. Skip suggestions for incidental changes that are unrelated to the PR's primary purpose, especially when the user explicitly requests to stay focused on the main feature/improvement.
🪛 HTMLHint (1.5.0)
website/modules/testimonials-carousel-widget/views/widget.html

[error] 47-47: Special characters must be escaped : [ > ].

(spec-char-escape)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: e2e-tests
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: security-scan
🔇 Additional comments (1)
website/modules/testimonials-carousel-widget/views/widget.html (1)

45-52: Anchor-strip “www.” when extracting domain

  • File: website/modules/testimonials-carousel-widget/views/widget.html, around lines 45–52

Replace the unanchored global replace:

-{% set cleanDomain = domainWithOrWithoutWww | trim | replace('www.', '') %}
+{# Strip only a leading “www.” #}
+{% set cleanDomain = domainWithOrWithoutWww
+  | trim
+  | replace('^www\\.', '', regex=true) %}

Ensure your Nunjucks version supports the regex=true argument; otherwise fall back to a simple prefix check:

{% set cleanDomain = domainWithOrWithoutWww %}
{% if cleanDomain.startswith('www.') %}
  {% set cleanDomain = cleanDomain.substr(4) %}
{% endif %}

@yuramax yuramax left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! 👍

@IhorMasechko IhorMasechko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2025

Copy link
Copy Markdown

@Anton-88 Anton-88 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@killev killev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good

@Anton-88
Anton-88 merged commit 1816425 into main Jul 3, 2025
12 checks passed
@Anton-88
Anton-88 deleted the 654-feat/testimonials-show-domain-only branch July 3, 2025 12:53
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.

5 participants