Skip to content

fix: Allow to pass a returnUrl when fetching public note URL#1677

Merged
zatteo merged 2 commits intomasterfrom
fix/allow-return-url-in-fetch-note
Mar 19, 2026
Merged

fix: Allow to pass a returnUrl when fetching public note URL#1677
zatteo merged 2 commits intomasterfrom
fix/allow-return-url-in-fetch-note

Conversation

@zatteo
Copy link
Copy Markdown
Member

@zatteo zatteo commented Mar 18, 2026

Summary by CodeRabbit

  • New Features

    • Added optional return URL support for shared/public links so receivers can be redirected back after viewing; URL generation now includes this parameter when provided.
  • Documentation

    • Updated API docs to describe the new return URL option and clarify the URL-generation parameters for consumers.

@zatteo zatteo requested a review from paultranvan as a code owner March 18, 2026 06:27
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 18, 2026

Warning

Rate limit exceeded

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

⌛ 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 169fef63-f3e1-4971-9d36-b40c8b207a4e

📥 Commits

Reviewing files that changed from the base of the PR and between 3fa7300 and 3abaf83.

📒 Files selected for processing (4)
  • docs/api/cozy-client/interfaces/models.note.FetchURLOptions.md
  • docs/api/cozy-client/modules/models.note.md
  • packages/cozy-client/src/models/note.js
  • packages/cozy-client/types/models/note.d.ts

Walkthrough

The note model's fetchURL signature was changed to destructure its options as { pathname, driveId, returnUrl } and a new FetchURLOptions typedef was added. When a sharecode is used, returnUrl is now conditionally appended as a returnUrl query parameter. JSDoc, TypeScript declarations, and API docs were updated to include returnUrl.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for passing a returnUrl parameter when fetching public note URLs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/allow-return-url-in-fetch-note
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/cozy-client/src/models/note.js (1)

46-52: Add a regression test for fetchURL public-link returnUrl behavior.

Lines 50-51 introduce new branch logic, but the provided tests only demonstrate returnUrl handling for generatePrivateUrl (not the fetchURL sharecode path). Please add a focused test to lock this behavior (including encoding expectations) and prevent silent regressions.

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

In `@packages/cozy-client/src/models/note.js` around lines 46 - 52, Add a
regression test that verifies fetchURL's public-link (sharecode) path correctly
includes and URL-encodes options.returnUrl: exercise the fetchURL (or the
public-link branch that reads sharecode) code path with a returnUrl containing
characters that require encoding, assert the generated URL has a returnUrl query
parameter with the expected percent-encoding, and also test behavior when
public_name is present so the searchParams branch (username/public_name) and
returnUrl coexist; mirror the style of the existing generatePrivateUrl tests
(same test harness/setup) to lock this behavior and prevent regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/cozy-client/src/models/note.js`:
- Around line 46-52: Add a regression test that verifies fetchURL's public-link
(sharecode) path correctly includes and URL-encodes options.returnUrl: exercise
the fetchURL (or the public-link branch that reads sharecode) code path with a
returnUrl containing characters that require encoding, assert the generated URL
has a returnUrl query parameter with the expected percent-encoding, and also
test behavior when public_name is present so the searchParams branch
(username/public_name) and returnUrl coexist; mirror the style of the existing
generatePrivateUrl tests (same test harness/setup) to lock this behavior and
prevent regressions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7eed5708-a084-421e-b0e5-a4ba0d6c2a3d

📥 Commits

Reviewing files that changed from the base of the PR and between cbb22ff and 4e28f92.

📒 Files selected for processing (1)
  • packages/cozy-client/src/models/note.js

@zatteo zatteo force-pushed the fix/allow-return-url-in-fetch-note branch from 4e28f92 to 49cbad7 Compare March 18, 2026 06:55
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In `@packages/cozy-client/types/models/note.d.ts`:
- Around line 3-7: Update the fetchURL type signature so the options properties
match implementation: mark pathname, driveId and returnUrl as optional in the
options object for export function fetchURL(client: object, file: object,
options?: { ... }) to prevent TS errors when callers omit them; locate the
fetchURL declaration in the note.d.ts and change those property types from
required string to optional (e.g. pathname?: string) so the declaration aligns
with the runtime checks (e.g. if (options.returnUrl)).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f4e9cea3-4a55-41fe-9374-d08cbb9dcc79

📥 Commits

Reviewing files that changed from the base of the PR and between 4e28f92 and 49cbad7.

📒 Files selected for processing (3)
  • docs/api/cozy-client/modules/models.note.md
  • packages/cozy-client/src/models/note.js
  • packages/cozy-client/types/models/note.d.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/api/cozy-client/modules/models.note.md

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

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 (1)
packages/cozy-client/src/models/note.js (1)

8-8: Clarify that returnUrl currently applies only to share/public URLs.

returnUrl is documented as a generic option, but it is only used when sharecode exists. Please clarify this in JSDoc (or add support in the non-sharecode branch if that was intended).

📝 Suggested clarification
- * `@property` {string} [returnUrl] - Return URL to add in query string
+ * `@property` {string} [returnUrl] - Return URL to add in query string (share/public URL flow)

Also applies to: 58-60, 70-76

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

In `@packages/cozy-client/src/models/note.js` at line 8, Update the JSDoc for the
`returnUrl` property to state it is only applied when a `sharecode`
(public/share URL) is present, or alternatively implement support for
`returnUrl` in the non-`sharecode` branch if that was intended; locate
references to `returnUrl` and the `sharecode` check in this module (the
`returnUrl` property JSDoc and the URL-building code that checks `sharecode`
around the other usages mentioned) and either change the comment to explicitly
say "applies only to share/public URLs when `sharecode` is provided" or add the
logic to append `returnUrl` in the non-`sharecode` path so behavior matches the
existing generic documentation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cozy-client/src/models/note.js`:
- Line 7: Update the JSDoc for the driveId property in
packages/cozy-client/src/models/note.js: locate the `@property` entry for driveId
and correct the description text from "used to fetched the URL" to "used to
fetch the URL" so the grammar is fixed while preserving the rest of the comment.

---

Nitpick comments:
In `@packages/cozy-client/src/models/note.js`:
- Line 8: Update the JSDoc for the `returnUrl` property to state it is only
applied when a `sharecode` (public/share URL) is present, or alternatively
implement support for `returnUrl` in the non-`sharecode` branch if that was
intended; locate references to `returnUrl` and the `sharecode` check in this
module (the `returnUrl` property JSDoc and the URL-building code that checks
`sharecode` around the other usages mentioned) and either change the comment to
explicitly say "applies only to share/public URLs when `sharecode` is provided"
or add the logic to append `returnUrl` in the non-`sharecode` path so behavior
matches the existing generic documentation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a3d9b83-be46-41c8-a4c8-8bc2b6d9f595

📥 Commits

Reviewing files that changed from the base of the PR and between 49cbad7 and 3fa7300.

📒 Files selected for processing (2)
  • packages/cozy-client/src/models/note.js
  • packages/cozy-client/types/models/note.d.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/cozy-client/types/models/note.d.ts

@zatteo zatteo force-pushed the fix/allow-return-url-in-fetch-note branch from 3fa7300 to f83be6b Compare March 19, 2026 06:37
@zatteo zatteo force-pushed the fix/allow-return-url-in-fetch-note branch from f83be6b to 3abaf83 Compare March 19, 2026 06:39
@zatteo zatteo merged commit 25e5719 into master Mar 19, 2026
4 checks passed
@zatteo zatteo deleted the fix/allow-return-url-in-fetch-note branch March 19, 2026 06:47
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