feature: allow realms to have dashes in name#51
Merged
Conversation
phalestrivir
requested changes
May 1, 2026
phalestrivir
left a comment
There was a problem hiding this comment.
I suggested some improvements to your code to help simplify it. The only other things you need to do is rebase with main (since there were some new changes added there) and then run npm run lint:fix after you make all the changes. Also double-check the tests are still passing in the lib/CLI, and then you should be good to go ahead and create the PR against Rockcarver.
Comment on lines
+143
to
+157
| if (realm === 'root') { | ||
| return '/'; | ||
| } | ||
| return realm.replace('root-', '/').replaceAll('-', '/'); | ||
|
|
||
| let stripped = realm.replace(/^root-/, ''); | ||
|
|
||
| stripped = stripped.replace(/--/g, '__DASH__'); | ||
|
|
||
| const parts = stripped.split(/-(?!_)/); | ||
|
|
||
| const decoded = parts.map((p) => | ||
| p.replace(/__DASH__/g, '-') | ||
| ); | ||
|
|
||
| return '/' + decoded.join('/'); |
There was a problem hiding this comment.
I don't like the idea of replacing the double dashes with a temporary string, it seems like a complicated solution to something that should be more simple. Here's a more simpler way to do this that I came up with using ChatGPT with help for the regex:
return realm === 'root' ? '/' : realm.replace(/^root-|--|-/g, m => m === '--' ? '-' : '/');3390f7b to
a64ea6e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Escape '-' as '--' to preserve literal dashes in realm names.