Skip to content

Consolidate duplicate path encoding functions #11

@Fuabioo

Description

@Fuabioo

Problem

There are two path encoding functions with different behavior:

  1. internal/config/config.go:172-186 - encodeProjectPath
  2. internal/history/paths.go:22-34 - EncodeProjectPath

Evidence

config.go version:

func encodeProjectPath(path string) string {
    result := ""
    for _, c := range path {
        if c == filepath.Separator {
            result += "-"
        } else if c == ':' {
            continue  // Skip Windows colon
        } else {
            result += string(c)  // KEEPS DOTS
        }
    }
    return result
}

paths.go version:

func EncodeProjectPath(path string) string {
    encoded := strings.ReplaceAll(path, string(filepath.Separator), "-")
    encoded = strings.ReplaceAll(encoded, ".", "-")  // REPLACES DOTS
    // ...
}

The key difference: history.EncodeProjectPath replaces dots with dashes, while config.encodeProjectPath preserves dots.

Impact

This inconsistency could cause path mismatches if both functions are used in different parts of the codebase with the expectation of matching results.

Suggested Fix

  1. Delete the private config.encodeProjectPath function
  2. Use the public history.EncodeProjectPath everywhere
  3. The history package version should be canonical since it's the public API

Files:

  • internal/config/config.go:172-186
  • internal/history/paths.go:22-34

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions