@@ -87,7 +87,12 @@ func (p Pass) Add(creds *credentials.Credentials) error {
8787
8888 encoded := base64 .URLEncoding .EncodeToString ([]byte (creds .ServerURL ))
8989
90- _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , creds .Username ))
90+ username := creds .Username
91+ if strings .Contains (username , "/" ) {
92+ username = base64 .URLEncoding .EncodeToString ([]byte (creds .Username ))
93+ }
94+
95+ _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , username ))
9196 return err
9297}
9398
@@ -160,8 +165,13 @@ func (p Pass) Get(serverURL string) (string, string, error) {
160165 }
161166
162167 actual := strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
168+ username := actual
169+ decodedUsername , err := base64 .URLEncoding .DecodeString (actual )
170+ if err == nil {
171+ username = string (decodedUsername )
172+ }
163173 secret , err := p .runPass ("" , "show" , path .Join (PASS_FOLDER , encoded , actual ))
164- return actual , secret , err
174+ return username , secret , err
165175}
166176
167177// List returns the stored URLs and corresponding usernames for a given credentials label
@@ -193,6 +203,10 @@ func (p Pass) List() (map[string]string, error) {
193203 }
194204
195205 resp [string (serverURL )] = strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
206+ decodedUsername , err := base64 .URLEncoding .DecodeString (strings .TrimSuffix (usernames [0 ].Name (), ".gpg" ))
207+ if err == nil {
208+ resp [string (serverURL )] = string (decodedUsername )
209+ }
196210 }
197211
198212 return resp , nil
0 commit comments