Skip to content

custom safepath #150

Description

@quantenzitrone

Problem

i am not fully satisfied with how the safepath function works

solution

optimally i would like to have a way to make a safepath that does what i had with beets:

replace: {
  # remove invisible characters like null and control codes
  '[\x00-\x1f]': "",
  # remove spaces at the beginning and end
  \s+$: "",
  ^\s+: "",
  # replace path separator with similar looking unicode
  /: "",
  # replace dot at the beginning with similar looking unicode
  ^\.: "",
}

alternatively i would like to have:

  • separate safepath and ASCIIization
  • a safepath that doesn't care about Microsoft Windows

ideas for implementation

idea1:

  • keep the current safepath as is for backwards compat
  • make new functions safepathUnix safepathWindows and asciiize or normalizeUnicode that implement the alternative solution

idea2:

  • a replace function with regular expressions

idea3:

  • a config option that customizes what safepath does

If you want, I could try to implement idea1, idea2 or something similar.
While i have never worked with go, looking at the code it seems pretty easy with the existing code as guidance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions