@@ -88,7 +88,12 @@ func (p Pass) Add(creds *credentials.Credentials) error {
8888
8989 encoded := base64 .URLEncoding .EncodeToString ([]byte (creds .ServerURL ))
9090
91- _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , creds .Username ))
91+ username := creds .Username
92+ if strings .Contains (username , "/" ) {
93+ username = base64 .URLEncoding .EncodeToString ([]byte (creds .Username ))
94+ }
95+
96+ _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , username ))
9297 return err
9398}
9499
@@ -161,8 +166,13 @@ func (p Pass) Get(serverURL string) (string, string, error) {
161166 }
162167
163168 actual := strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
169+ username := actual
170+ decodedUsername , err := base64 .URLEncoding .DecodeString (actual )
171+ if err == nil {
172+ username = string (decodedUsername )
173+ }
164174 secret , err := p .runPass ("" , "show" , path .Join (PASS_FOLDER , encoded , actual ))
165- return actual , secret , err
175+ return username , secret , err
166176}
167177
168178// List returns the stored URLs and corresponding usernames for a given credentials label
@@ -194,6 +204,10 @@ func (p Pass) List() (map[string]string, error) {
194204 }
195205
196206 resp [string (serverURL )] = strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
207+ decodedUsername , err := base64 .URLEncoding .DecodeString (strings .TrimSuffix (usernames [0 ].Name (), ".gpg" ))
208+ if err == nil {
209+ resp [string (serverURL )] = string (decodedUsername )
210+ }
197211 }
198212
199213 return resp , nil
0 commit comments