Skip to content

Conversation

mruediger
Copy link

By replacing string.Split in ParseVaultAndItemFromPath with a regexp,
you can use vault and item names containing slashes

By replacing string.Split in ParseVaultAndItemFromPath with a regexp,
you can use vault and item names containing slashes
@mruediger
Copy link
Author

Is there anything I can do to help with the required review?

if len(splitPath) == 4 && splitPath[0] == "vaults" && splitPath[2] == "items" {
return splitPath[1], splitPath[3], nil
r := regexp.MustCompile("vaults/(.*)/items/(.*)")
splitPath := r.FindAllStringSubmatch(path, -1)
Copy link
Contributor

@AndyTitu AndyTitu Jul 14, 2025

Choose a reason for hiding this comment

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

A little bit shorter but does the same thing:

Suggested change
splitPath := r.FindAllStringSubmatch(path, -1)
splitPath := r.FindStringSubmatch(path)

since we expect a single match anyway. Otherwise, injecting another vaults/.../items/... in the path could lead to an unexpected result.

We could also add another unit test case for the vaults/foo1/items/bar1/vaults/foo2/items/bar2 example

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