Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuzu committed Jan 24, 2024
1 parent 968b43d commit 41f6e97
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WORKDIR /app/
ADD . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o /palog .

FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine:3.19
FROM --platform=${TARGETPLATFORM:-linux/amd64} debian:bookworm-slim
COPY --from=builder /palog /palog
RUN apk add --no-cache icu

Expand Down
29 changes: 21 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ func init() {
}
}

func escapeString(s string) string {
s = strings.ReplaceAll(s, " ", "_")

if !uconvLatin {
return s
}

func runUconvLatin(s string) string {
var out strings.Builder
cmd := exec.Command("uconv", "-x", "latin")
cmd.Stdin = strings.NewReader(s)
Expand All @@ -68,7 +62,26 @@ func escapeString(s string) string {
return s
}

return strings.TrimSpace(out.String())
return out.String()
}

func escapeString(s string) string {
if uconvLatin {
s = runUconvLatin(s)
}
s = strings.ReplaceAll(s, " ", "_")
s = strings.TrimSpace(s)

runes := []rune(s)
for i := range runes {
b := []byte(string(runes[i]))

if len(b) != 1 {
runes[i] = '*'
}
}

return string(runes)
}

func main() {
Expand Down

0 comments on commit 41f6e97

Please sign in to comment.