Skip to content

[WEB-3797] fix: remove leading slash from URL to copy#6890

Merged
sriramveeraghanta merged 2 commits intopreviewfrom
fix/url-copy
Apr 8, 2025
Merged

[WEB-3797] fix: remove leading slash from URL to copy#6890
sriramveeraghanta merged 2 commits intopreviewfrom
fix/url-copy

Conversation

@aaryan610
Copy link
Member

@aaryan610 aaryan610 commented Apr 8, 2025

Description

This PR updates the copyURLTpClipboard function to handle URLs with a leading slash.

Also, this removes the function from web app and updates all of its instances to import it from the utils package.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Summary by CodeRabbit

  • Bug Fixes

    • Improved URL formatting when copying links so that shared URLs display correctly without extra slashes.
  • Refactor

    • Unified the link copying functionality across various screens, streamlining the process for a more consistent and reliable user experience.
    • Updated the source of the URL copying function to enhance code organization and clarity.

@aaryan610 aaryan610 changed the title fix: remove leading slash from URL to copy [WEB_3797] fix: remove leading slash from URL to copy Apr 8, 2025
@aaryan610 aaryan610 changed the title [WEB_3797] fix: remove leading slash from URL to copy [WEB-3797] fix: remove leading slash from URL to copy Apr 8, 2025
@makeplane
Copy link

makeplane bot commented Apr 8, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 8, 2025

Walkthrough

This update consolidates the implementation of the copyUrlToClipboard function by relocating it from the old helper to the new centralized @plane/utils module. The function logic was modified to ensure proper URL formatting by creating a URL object. Across multiple web components, the import paths have been updated, and the redundant boolean parameter has been removed from function calls. Additionally, the obsolete function was deleted from the original helper file, streamlining the utility function usage.

Changes

File(s) Change Summary
packages/utils/src/string.ts Updated copyUrlToClipboard to create a URL object for proper URL formatting.
web/helpers/string.helper.ts Removed the copyUrlToClipboard function and its associated documentation.
web/core/components/issues/create-issue-toast-action-items.tsx, .../quick-action-dropdowns/all-issue.tsx, .../quick-action-dropdowns/cycle-issue.tsx, .../quick-action-dropdowns/module-issue.tsx, .../quick-action-dropdowns/project-issue.tsx, .../peek-overview/header.tsx Updated import of copyUrlToClipboard from "@/helpers/string.helper" to "@plane/utils" and removed the redundant boolean argument from function calls.
web/core/hooks/use-page-operations.ts Revised the import path for copyUrlToClipboard and updated the preceding comment from // plane constants to // plane imports.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Component
    participant ClipboardUtil as copyUrlToClipboard
    participant ClipboardAPI

    User->>Component: Trigger copy URL action
    Component->>ClipboardUtil: Call copyUrlToClipboard(workItemLink)
    ClipboardUtil->>ClipboardAPI: Copy full URL <originUrl + workItemLink>
    ClipboardAPI-->>ClipboardUtil: Copy confirmation
    ClipboardUtil-->>Component: Return success status
Loading

Poem

I'm a rabbit with a hop in my step,
The code is now tidier—clean and adept.
No extra slash to trip my feet,
Centralized utils make it all neat.
Hopping through updates with joy so pure,
I celebrate changes both simple and sure!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a3a92af and a2f84bb.

📒 Files selected for processing (1)
  • packages/utils/src/string.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/utils/src/string.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
packages/utils/src/string.ts (1)

90-90: Improved URL handling to prevent double slashes.

The added code properly removes leading slashes from paths, ensuring correct URL formation when concatenated with the origin. This fixes the issue mentioned in the PR objectives.

Consider adding a null/empty check before accessing path[0] to make the function more robust:

-  if (path[0] === "/") path = path.slice(1);
+  if (path && path.length > 0 && path[0] === "/") path = path.slice(1);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 96c403f and a3a92af.

📒 Files selected for processing (9)
  • packages/utils/src/string.ts (1 hunks)
  • web/core/components/issues/create-issue-toast-action-items.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-action-dropdowns/all-issue.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-action-dropdowns/cycle-issue.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-action-dropdowns/module-issue.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-action-dropdowns/project-issue.tsx (2 hunks)
  • web/core/components/issues/peek-overview/header.tsx (2 hunks)
  • web/core/hooks/use-page-operations.ts (1 hunks)
  • web/helpers/string.helper.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • web/helpers/string.helper.ts
🧰 Additional context used
🧬 Code Definitions (5)
web/core/components/issues/issue-layouts/quick-action-dropdowns/cycle-issue.tsx (1)
packages/utils/src/string.ts (1)
  • copyUrlToClipboard (88-92)
web/core/components/issues/issue-layouts/quick-action-dropdowns/all-issue.tsx (1)
packages/utils/src/string.ts (1)
  • copyUrlToClipboard (88-92)
web/core/components/issues/create-issue-toast-action-items.tsx (1)
packages/utils/src/string.ts (1)
  • copyUrlToClipboard (88-92)
web/core/components/issues/peek-overview/header.tsx (1)
packages/utils/src/string.ts (1)
  • copyUrlToClipboard (88-92)
web/core/components/issues/issue-layouts/quick-action-dropdowns/module-issue.tsx (1)
packages/utils/src/string.ts (1)
  • copyUrlToClipboard (88-92)
🔇 Additional comments (15)
web/core/hooks/use-page-operations.ts (1)

2-2: Import update and comment correction.

The import for copyUrlToClipboard has been correctly updated to the new central location in @plane/utils, and the comment has been changed from "plane constants" to "plane imports" to better reflect the import section content.

Also applies to: 7-7

web/core/components/issues/issue-layouts/quick-action-dropdowns/cycle-issue.tsx (2)

8-12: Updated import sources for Plane utilities.

The import for copyUrlToClipboard has been correctly relocated from the local helper to the central @plane/utils package.


71-72: Simplified function call to match updated API.

The second parameter has been removed from the copyUrlToClipboard call, aligning with the new implementation in @plane/utils that only requires the path parameter.

web/core/components/issues/issue-layouts/quick-action-dropdowns/project-issue.tsx (2)

8-13: Updated import sources for Plane utilities.

The import for copyUrlToClipboard has been correctly relocated from the local helper to the central @plane/utils package.


76-77: Simplified function call to match updated API.

The second parameter has been removed from the copyUrlToClipboard call, aligning with the new implementation in @plane/utils that only requires the path parameter.

web/core/components/issues/peek-overview/header.tsx (2)

21-21: Import path updated correctly.

The import of copyUrlToClipboard has been properly updated to use the centralized version from @plane/utils rather than the local helper. This aligns with the PR's goal of consolidating utility functions.


110-110: Function call updated correctly.

The second parameter has been removed from the copyUrlToClipboard function call, which matches the new function signature in the utils package. The new implementation correctly handles paths with leading slashes internally.

web/core/components/issues/issue-layouts/quick-action-dropdowns/module-issue.tsx (3)

8-9: Comment organization improved.

The comment has been appropriately updated from "// types" to "// plane imports" to better reflect the nature of the imports that follow it.


12-12: Import path updated correctly.

The import of copyUrlToClipboard has been properly updated to use the centralized version from @plane/utils rather than the local helper, aligning with the PR's objective.


71-72: Function call updated correctly.

The second parameter has been removed from the copyUrlToClipboard function call, which aligns with the updated function signature in the utils package. The new implementation in @plane/utils now handles leading slashes within the function itself.

web/core/components/issues/issue-layouts/quick-action-dropdowns/all-issue.tsx (3)

8-9: Comment organization improved.

The comment has been appropriately updated from "// types" to "// plane imports" to better reflect the nature of the imports that follow it.


12-12: Import path updated correctly.

The import of copyUrlToClipboard has been properly updated to use the centralized version from @plane/utils, which consolidates the utility function as intended in the PR.


63-64: Function call updated correctly.

The second parameter has been removed from the copyUrlToClipboard function call, aligning with the new function signature. The updated implementation in the utils package now handles URL paths with leading slashes internally.

web/core/components/issues/create-issue-toast-action-items.tsx (2)

4-5: Import restructured correctly.

The import has been properly updated to use the standardized copyUrlToClipboard from @plane/utils and the comment has been updated to "// plane imports" to accurately categorize the import.


45-45: Function call updated correctly.

The second parameter has been removed from the copyUrlToClipboard function call, which aligns with the new function signature in the utils package. The updated implementation now handles leading slashes in the URL path internally.

@sriramveeraghanta sriramveeraghanta merged commit 3769936 into preview Apr 8, 2025
5 of 6 checks passed
@sriramveeraghanta sriramveeraghanta deleted the fix/url-copy branch April 8, 2025 09:52
lifeiscontent pushed a commit that referenced this pull request Aug 18, 2025
* fix: remove prefix slash if present

* chore: make use of URL class to generate a valid URL
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