@@ -91,7 +91,12 @@ func (p Pass) Add(creds *credentials.Credentials) error {
9191
9292 encoded := base64 .URLEncoding .EncodeToString ([]byte (creds .ServerURL ))
9393
94- _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , creds .Username ))
94+ username := creds .Username
95+ if strings .Contains (username , "/" ) {
96+ username = base64 .URLEncoding .EncodeToString ([]byte (creds .Username ))
97+ }
98+
99+ _ , err := p .runPass (creds .Secret , "insert" , "-f" , "-m" , path .Join (PASS_FOLDER , encoded , username ))
95100 return err
96101}
97102
@@ -164,8 +169,13 @@ func (p Pass) Get(serverURL string) (string, string, error) {
164169 }
165170
166171 actual := strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
172+ username := actual
173+ decodedUsername , err := base64 .URLEncoding .DecodeString (actual )
174+ if err == nil {
175+ username = string (decodedUsername )
176+ }
167177 secret , err := p .runPass ("" , "show" , path .Join (PASS_FOLDER , encoded , actual ))
168- return actual , secret , err
178+ return username , secret , err
169179}
170180
171181// List returns the stored URLs and corresponding usernames for a given credentials label
@@ -197,6 +207,10 @@ func (p Pass) List() (map[string]string, error) {
197207 }
198208
199209 resp [string (serverURL )] = strings .TrimSuffix (usernames [0 ].Name (), ".gpg" )
210+ decodedUsername , err := base64 .URLEncoding .DecodeString (strings .TrimSuffix (usernames [0 ].Name (), ".gpg" ))
211+ if err == nil {
212+ resp [string (serverURL )] = string (decodedUsername )
213+ }
200214 }
201215
202216 return resp , nil
0 commit comments