@@ -89,7 +89,12 @@ func (p Pass) Add(creds *credentials.Credentials) error {
8989
9090 encoded := base64 .URLEncoding .EncodeToString ([]byte (creds .ServerURL ))
9191
92- _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , creds .Username ))
92+ username := creds .Username
93+ if strings .Contains (username , "/" ) {
94+ username = base64 .URLEncoding .EncodeToString ([]byte (creds .Username ))
95+ }
96+
97+ _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , username ))
9398 return err
9499}
95100
@@ -162,8 +167,13 @@ func (p Pass) Get(serverURL string) (string, string, error) {
162167 }
163168
164169 actual := strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
170+ username := actual
171+ decodedUsername , err := base64 .URLEncoding .DecodeString (actual )
172+ if err == nil {
173+ username = string (decodedUsername )
174+ }
165175 secret , err := p .runPass ("" , "show" , path .Join (PASS_FOLDER , encoded , actual ))
166- return actual , secret , err
176+ return username , secret , err
167177}
168178
169179// List returns the stored URLs and corresponding usernames for a given credentials label
@@ -195,6 +205,10 @@ func (p Pass) List() (map[string]string, error) {
195205 }
196206
197207 resp [string (serverURL )] = strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
208+ decodedUsername , err := base64 .URLEncoding .DecodeString (strings .TrimSuffix (usernames [0 ].Name (), ".gpg" ))
209+ if err == nil {
210+ resp [string (serverURL )] = string (decodedUsername )
211+ }
198212 }
199213
200214 return resp , nil
0 commit comments