Skip to content

[WIP] Update package name sanitization behavior#2

Merged
punppis merged 1 commit into
mainfrom
copilot/update-package-name-sanitization
Jan 29, 2026
Merged

[WIP] Update package name sanitization behavior#2
punppis merged 1 commit into
mainfrom
copilot/update-package-name-sanitization

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 29, 2026

Update Package Name Sanitization in create-package Tool

Problem

The current implementation uses tr ' _' '-' which only handles spaces and underscores, but doesn't handle other whitespace characters like tabs. This causes tabs to be removed instead of converted to dashes.

Solution

  • Understand the current implementation and identify the issue
  • Update the sanitization logic in create-package script
    • Changed tr ' _' '-' to tr -s '[:space:]_' '-' to handle all whitespace
    • The -s flag squeezes consecutive characters into one
    • [:space:] matches all whitespace (spaces, tabs, newlines, etc.)
  • Update README.md documentation to reflect the improved sanitization
  • Test the changes with various inputs including tabs, multiple spaces, and special characters
  • Verify all examples from the problem statement work correctly

Changes Made

  1. create-package script (line 46): Changed tr ' _' '-' to tr -s '[:space:]_' '-'

    • Now handles all whitespace characters (tabs, multiple spaces, etc.)
    • The -s flag automatically collapses consecutive whitespace into a single dash
  2. README.md: Updated sanitization documentation to clarify that all whitespace characters are handled

Examples Validated ✓

  • "my repo" -> "my-repo" ✓
  • "my ^ repo2" -> "my-repo2" ✓
  • "my\trepo" (with tab) -> "my-repo" ✓
  • "my\t\trepo" (multiple tabs) -> "my-repo" ✓
  • "TEST___REPO" (multiple underscores) -> "test-repo" ✓
Original prompt

Update the existing PR in punppis/linux-utils (PR #1: #1, branch copilot/add-create-package-tool) to adjust package name sanitization behavior.

New sanitization rules (must match examples):

  • Lowercase everything.
  • Convert any run of whitespace characters (including multiple spaces, tabs) into a single dash -.
  • Remove special characters.
  • Allowed characters in final name: lowercase letters a-z, digits 0-9, and dash -.
  • Collapse multiple dashes to a single dash, and trim leading/trailing dashes.

Examples:

  • "my repo" -> "my-repo"
  • "my ^ repo2" -> "my-repo2"

Notes:

  • The current implementation uses tr ' _' '-' which does not collapse runs of whitespace into a single dash before removing special chars in all cases; update accordingly.
  • Update README documentation in the PR if it mentions sanitization specifics.
  • Keep Debian/Ubuntu compatibility; prefer POSIX-ish utilities (tr, sed, awk) available by default.

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@punppis punppis marked this pull request as ready for review January 29, 2026 22:03
@punppis punppis merged commit 2cf812a into main Jan 29, 2026
1 check failed
Copilot AI requested a review from punppis January 29, 2026 22:03
Copilot stopped work on behalf of punppis due to an error January 29, 2026 22:03
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