Skip to content

Use one word-boundary algorithm for placeholder segments #70

Description

@felixarntz

Placeholder segment behavior is inconsistent: case conversion and segments(n) split some camel-case, hyphen, and underscore boundaries, while toNthSegment splits only on hyphens, and spaces are not handled consistently. Any word boundary in a name should mean the same thing everywhere, including spaces, hyphens, underscores, and uppercase transitions in camelCase or PascalCase names.

Relevant files:

  • packages/konsistent/src/core/case-utils.ts
  • packages/konsistent/src/core/placeholder.ts
  • packages/konsistent/src/core/constraints/segments.ts
  • packages/konsistent/src/config/schema.ts
  • packages/konsistent/src/config/cli-placeholders.ts

Implement one canonical word-splitting function and use it for segment constraints, nth-segment transforms, and case transforms. Update placeholder value validation where necessary so supported inputs can contain every documented boundary form, with shared tests covering all boundary types.

Backward compatibility: internal helpers and documentation can be renamed or replaced without compatibility shims. If accepted placeholder values or any konsistent.json behavior changes, keep the old behavior available as deprecated where it can be selected explicitly and emit a non-failing CLI warning for deprecated usage.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions