Skip to content

fix: 🐛 Fix operator precedence in About customer URL href#57

Open
wapec wants to merge 1 commit into
Euro-Office:mainfrom
wapec:fix/about-url-operator-precedence
Open

fix: 🐛 Fix operator precedence in About customer URL href#57
wapec wants to merge 1 commit into
Euro-Office:mainfrom
wapec:fix/about-url-operator-precedence

Conversation

@wapec
Copy link
Copy Markdown
Contributor

@wapec wapec commented May 5, 2026

The ternary and string concatenation were not grouped correctly — due to operator precedence, the expression evaluated as:
condition ? 'http://' : urlCustomer
instead of:
(condition ? 'http://' : '') + urlCustomer

When urlCustomer had no scheme, href became 'http://' with the actual URL silently dropped. Affects all white-labelled installations supplying customization.customer.www without a protocol prefix.

How to verify — logic level

Paste into any browser DevTools console:

const buggy = url => !/^https?:\/{2}/i.test(url) ? "http://" : '' + url;
const fixed = url => (!/^https?:\/{2}/i.test(url) ? 'http://' : '') + url;

console.table([
    'example.com',
    'www.example.com',
    'https://example.com',
    'http://example.com',
    'HTTPS://example.com',
].map(input => ({ input, buggy: buggy(input), fixed: fixed(input) })));

Expected output:

input buggy fixed
example.com http:// http://example.com
example.com http:// http://example.com
www.example.com http:// http://www.example.com
https://example.com https://example.com https://example.com
http://example.com http://example.com http://example.com
HTTPS://example.com HTTPS://example.com HTTPS://example.com

Only inputs without an http:// / https:// scheme expose the bug. The
last three rows confirm the fix doesn't regress URLs that previously worked.

How to verify — UI

Open the mobile editor with customization.customer.www set in the editor
config. Navigate to Settings → About and inspect the customer URL link
(#settings-about-url):

<!-- buggy build, customer.www = "example.com" -->
<a id="settings-about-url" class="link external" href="http://" target="_blank">example.com</a>

<!-- fixed build, customer.www = "example.com" -->
<a id="settings-about-url" class="link external" href="http://example.com" target="_blank">example.com</a>

The visible link text is identical in both builds — only href differs,
which is why the bug is easy to miss in casual visual review.

Screenshots (Pixel 5, dark theme)

Input Before (buggy) After (fixed)
example.com buggy no-scheme fixed no-scheme
www.example.com buggy no-scheme-www fixed no-scheme-www

The red/green banner overlay at the top of each screenshot shows the actual
href attribute on the rendered link — that's where the divergence lives.

Test checklist

  • customer.www = "example.com" → link href = http://example.com, click opens the site
  • customer.www = "www.example.com" → link href = http://www.example.com, click opens the site
  • customer.www = "http://example.com" → link href unchanged, click opens the site
  • customer.www = "https://example.com" → link href unchanged, click opens the site
  • customer.www = "HTTPS://example.com" → link href unchanged (case-insensitive)
  • customer.www unset → link not rendered (existing urlCustomer?.length guard)

The ternary and string concatenation were not grouped correctly — due to
operator precedence, the expression evaluated as:
  condition ? 'http://' : urlCustomer
instead of:
  (condition ? 'http://' : '') + urlCustomer

When urlCustomer had no scheme, href became 'http://' with the actual
URL silently dropped. Affects all white-labelled installations supplying
customization.customer.www without a protocol prefix.

Signed-off-by: Bohdan Baranov <wapec@icloud.com>
@wapec wapec marked this pull request as ready for review May 29, 2026 07:37
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.

1 participant