Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
Filter for Unicode and Dots
Browse files Browse the repository at this point in the history
  • Loading branch information
fionera committed Feb 6, 2020
1 parent 42d9596 commit d6286e5
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/generate/rclone/rclone.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"strings"
"unicode"

"github.com/sirupsen/logrus"
"github.com/urfave/cli"
Expand Down Expand Up @@ -71,7 +72,23 @@ func CmdCreateProject(c *cli.Context) {
continue
}

sb.WriteString(fmt.Sprintf("[%s]\n", strings.NewReplacer("/", "_", " ", "").Replace(teamDrive.Name)))
name := strings.Map(func(r rune) rune {
if r > unicode.MaxASCII {
return -1
}
return r
}, teamDrive.Name)

name = strings.Map(func(r rune) rune {
if r == '/' ||
r == '_' ||
r == '.' {
return '-'
}
return r
}, name)

sb.WriteString(fmt.Sprintf("[%s]\n", name))
sb.WriteString("type = drive\n")
sb.WriteString("scope = drive\n")
sb.WriteString(fmt.Sprintf("teamdrive_id = %s\n", teamDrive.Id))
Expand Down

0 comments on commit d6286e5

Please sign in to comment.