Skip to content

Conversation

@emilhovh
Copy link

Prevent absolute file paths (e.g., /Desktop/file, /home/user/project) from being incorrectly detected as slash commands by checking if the first word after '/' contains another '/'.

  • Updated isSlashCommand() to filter out absolute file paths
  • Added comprehensive test cases for file path detection
  • Ensures valid slash commands like /help, /memory still work correctly

Prevent absolute file paths (e.g., /Desktop/file, /home/user/project) from
being incorrectly detected as slash commands by checking if the first word
after '/' contains another '/'.

- Updated isSlashCommand() to filter out absolute file paths
- Added comprehensive test cases for file path detection
- Ensures valid slash commands like /help, /memory still work correctly
// Exclude absolute file paths (e.g., /Desktop/file, /home/user/project)
// Check if there's a second '/' in the first word (before any space)
// This catches patterns like /Desktop/, /home/, /usr/, etc.
const afterSlash = query.substring(1);

Choose a reason for hiding this comment

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

Consider adding the @ symbold if its a path to comply with the standard path designation.

// Check if there's a second '/' in the first word (before any space)
// This catches patterns like /Desktop/, /home/, /usr/, etc.
const afterSlash = query.substring(1);
const firstWord = afterSlash.split(/\s/)[0];

Choose a reason for hiding this comment

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

Can we cover "" paths for windows as well?

Add comment suggesting users should use @/path/to/file instead of
/path/to/file to comply with the standard file path designation.
Add support for detecting and excluding Windows paths (e.g., C:\Users\...,
\path\to\file) from being treated as slash commands.

- Updated isSlashCommand() to check for backslashes in addition to forward slashes
- Added test cases for Windows-style paths
- Updated documentation to mention Windows path support
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