Skip to content

Fix Rendelhető items url - #190

Merged
MiklosBacsi merged 3 commits into
masterfrom
fix/items-url
Apr 25, 2026
Merged

MiklosBacsi merged 3 commits into
masterfrom
fix/items-url

Conversation

@MiklosBacsi

@MiklosBacsi MiklosBacsi commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Corrected filter navigation link URL formatting for consistent query string handling.
  • Refactor

    • Streamlined URL routing patterns for product filter navigation links to use standardized query parameter syntax.

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@MiklosBacsi has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 12 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 12 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0b00729-0dd6-46fe-8903-c2bdd391534d

📥 Commits

Reviewing files that changed from the base of the PR and between 7356499 and aae71c3.

📒 Files selected for processing (2)
  • mvnw
  • src/main/resources/static/js/item.js
📝 Walkthrough

Walkthrough

URL path construction for item filters is standardized across JavaScript and HTML template code. The JavaScript getFilter() function now produces routes with leading slashes (/now, /tomorrow), and the HTML template filter links are updated to use cleaner route expressions without redundant slashes or query separators, ensuring consistency between frontend route generation and template navigation.

Changes

Cohort / File(s) Summary
Frontend Route Normalization
src/main/resources/static/js/item.js, src/main/resources/templates/items.html
Updated item filter route construction to use consistent path formatting. JavaScript getFilter() now returns routes with leading slashes (/now, /tomorrow); HTML template filter links changed from redundant formats (/items/?now) to standard query forms (/items?now). Added console logging of URL parameters in JavaScript fetch handler.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hop-hop, the paths are now so clean,
No slashes doubled—never seen!
From /items/?now to /items?now we go,
Routes aligned in orderly row! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix Rendelhető items url' is partially related to the changeset - it indicates a URL fix for items, which matches the actual changes to item.js and items.html URL construction. However, the title lacks specificity about what the actual issue was (the route suffix format change) and uses a non-English term that may be unclear to some reviewers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/items-url

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/resources/static/js/item.js`:
- Line 691: Remove the leftover debug statement that logs URL_BASE and path on
every GET: delete the console.log("URL_BASE: " + URL_BASE + "\tpath: " + path)
call in src/main/resources/static/js/item.js (the line referencing URL_BASE and
path) or replace it with a conditional debug logger controlled by a debug flag
so it does not log in production.
- Around line 58-64: getFilter currently returns values with a leading '/' which
breaks updateUrl because the slash ends up in the query string, losing the
filter on reload; fix by making getFilter return the bare token ('now' or
'tomorrow' or '') and prepend '/' only where used as a path (e.g., where you
build API paths or call fetch items), or alternatively, keep getFilter as-is but
change updateUrl to strip a leading '/' when composing the query string; update
the getFilter and updateUrl usages accordingly so path-building uses '/' +
getFilter() while query-building uses getFilter().replace(/^\/+/,'').
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8bd0fa1-935f-4e4a-8ee4-02c661af9e2b

📥 Commits

Reviewing files that changed from the base of the PR and between 075625c and 7356499.

📒 Files selected for processing (2)
  • src/main/resources/static/js/item.js
  • src/main/resources/templates/items.html

Comment on lines 58 to 64
function getFilter(separator) {
if (location.search.includes('?now'))
return 'now' + separator;
return '/now' + separator;
if (location.search.includes('?tomorrow'))
return 'tomorrow' + separator;
return '/tomorrow' + separator;
return '';
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

updateUrl() is now broken — the leading / ends up inside the query string.

getFilter('') is also consumed by updateUrl() (lines 90–95). With the new return value '/now' / '/tomorrow', the produced history URLs become:

  • '/items' + '?' + '/now'/items?/now
  • '/items?' + '/now' + '&' + 'q=...'/items?/now&q=...

After this pushState, location.search is ?/now…, and location.search.includes('?now') returns false, so on the very next interaction getFilter() returns '' and the now/tomorrow filter is silently dropped from api/items calls (and from any reload/share of that URL). This regresses the same filter behavior the PR is meant to fix.

Either keep getFilter() returning the bare token and prepend / only at the API call sites, or normalize in updateUrl(). Suggested minimal fix:

🔧 Proposed fix
 function getFilter(separator) {
     if (location.search.includes('?now'))
-        return '/now' + separator;
+        return 'now' + separator;
     if (location.search.includes('?tomorrow'))
-        return '/tomorrow' + separator;
+        return '/tomorrow' + separator.replace(/^/, '');
     return '';
 }

…and prepend the slash where the value is used as a path:

-    getForJsonObject('api/items' + getFilter('') + (profile !== parseInt(0) ? '?circle=' + profile : ''))
+    getForJsonObject('api/items' + (getFilter('') ? '/' + getFilter('') : '') + (profile !== parseInt(0) ? '?circle=' + profile : ''))
-    getForJsonObject('api/items' + getFilter(''))
+    getForJsonObject('api/items' + (getFilter('') ? '/' + getFilter('') : ''))

Alternatively, leave getFilter() as-is in this PR and patch updateUrl() to strip the leading / when composing the query string.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/resources/static/js/item.js` around lines 58 - 64, getFilter
currently returns values with a leading '/' which breaks updateUrl because the
slash ends up in the query string, losing the filter on reload; fix by making
getFilter return the bare token ('now' or 'tomorrow' or '') and prepend '/' only
where used as a path (e.g., where you build API paths or call fetch items), or
alternatively, keep getFilter as-is but change updateUrl to strip a leading '/'
when composing the query string; update the getFilter and updateUrl usages
accordingly so path-building uses '/' + getFilter() while query-building uses
getFilter().replace(/^\/+/,'').

Comment thread src/main/resources/static/js/item.js Outdated
@MiklosBacsi
MiklosBacsi merged commit 865e0fc into master Apr 25, 2026
2 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request May 9, 2026
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