Fix path matching in getResourceType to handle relative paths#691
Fix path matching in getResourceType to handle relative paths#691aaronpowell merged 2 commits intohooksfrom
Conversation
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes getResourceType() path classification so deep links using relative paths (stored in the URL hash) correctly detect hook and skill resources, restoring expected modal behavior.
Changes:
- Update skills path detection to match both relative (
skills/...) and absolute (/skills/...) paths. - Update hooks path detection to match both relative (
hooks/...) and absolute (/hooks/...) paths.
| if (filePath.endsWith(".agent.md")) return "agent"; | ||
| if (filePath.endsWith(".prompt.md")) return "prompt"; | ||
| if (filePath.endsWith(".instructions.md")) return "instruction"; | ||
| if (filePath.includes("/skills/") && filePath.endsWith("SKILL.md")) | ||
| if (/(^|\/)skills\//.test(filePath) && filePath.endsWith("SKILL.md")) | ||
| return "skill"; |
There was a problem hiding this comment.
getResourceType() returns "instruction" for .instructions.md, but the VS Code install config (VSCODE_INSTALL_CONFIG) is keyed by "instructions". In openFileModal(), getVSCodeInstallUrl(type, ...) will therefore return null for instruction files, hiding the install dropdown in the modal for instructions opened from the list or via deep link. Consider normalizing the type names (e.g., use "instructions" everywhere) or adding an alias mapping in getVSCodeInstallUrl so both "instruction" and "instructions" resolve to the same config entry.
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.Description
The
getResourceType()function used.includes("/hooks/")and.includes("/skills/")which failed to match relative paths stored in URL hashes (e.g.,hooks/pre-commit/README.md), causing deep links to classify resources as "unknown" and break modal behavior.Changes:
.includes("/hooks/")with regex/(^|\/)hooks\//.test()to match both relative and absolute pathsBefore:
After:
Pattern matches:
hooks/pre-commit/README.md✓/hooks/pre-commit/README.md✓Type of Contribution
Additional Notes
This PR addresses review feedback from #685: #685 (comment)
Merges into the
copilot/pr-685branch, notmain.By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.