jsr icon indicating copy to clipboard operation
jsr copied to clipboard

feat: Allow dots in organization/scope names

Open philkunz opened this issue 5 months ago • 1 comments

Updates validation rules to allow dots (.) in organization names while maintaining backward compatibility with existing names.

Backend changes:

  • Allow dots in ScopeName validation (api/src/ids.rs:30)
  • Prevent leading/trailing dots (e.g., .org, test.)
  • Prevent consecutive dots (e.g., foo..bar)
  • Add new error variants for dot validation
  • Add comprehensive test coverage for dot patterns

Frontend changes:

  • Update regex to allow dots (frontend/utils/ids.ts:9)
  • Remove underscore support to match backend validation
  • Add validation for leading/trailing dots
  • Add validation for consecutive dots
  • Update error messages for consistency

Valid examples: my.org, foo.bar, foo.bar.baz, org.name-123 Invalid examples: .foo, foo., foo..bar

Reasoning

Allow Open Source projects to mirror their project domain as org name.

PR Checklist

  • [x] The PR title follows conventional commits
  • [x] Is this closing an open issue? If so, link it, else include a proper description of the changes and rason behind them.
  • [x] Does the PR have changes to the frontend? If so, include screenshots or a recording of the changes.
    If it affect colors, please include screenshots/recording in both light and dark mode.
  • [x] Does the PR have changes to the backend? If so, make sure tests are added.
    And if changing dababase queries, be sure you have ran sqlx prepare and committed the changes in the .sqlx directory.

philkunz avatar Oct 24 '25 11:10 philkunz

While I don't think allowing dots in scope names is wrong in principle, it provides some challenges beyond just widening the allowed characters on the jsr website and backend.

@philkunz Maybe discuss this with the JSR maintainers during their open office meeting: https://discord.gg/V3z7A25S?event=1388890175240667197

These are the problems I can think of:


On Windows machines, it is problematic to install packages using a dot in their name. image And the package name will need to be wrapped in quotes like this: npx jsr add "@foo.example/bar". This will cause the default copy-able command in jsr.io to fail. image psd

I am not sure if wrapping the package name in quotes has effects on other operating systems


The jsr CLI tool will also need to be modified, as it does its own check for valid scope/package names here: https://github.com/jsr-io/jsr-npm/blob/main/src/utils.ts

image

(Maybe deno add and other package managers too)

Ionaru avatar Oct 24 '25 21:10 Ionaru