Found and addressed some possible path issues

This commit is contained in:
asdf 2019-10-27 23:24:52 +11:00
parent d727f22fe7
commit be4741895e
2 changed files with 6 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"strconv"
@ -504,6 +505,7 @@ func (c *client) getCurrentPageRawData() (string, error) {
return c.PageState.History[c.PageState.Position].RawContent, nil
}
// Saves the specified URL to the specified file path.
func (c *client) saveFile(u Url, name string) {
var file []byte
var err error
@ -849,8 +851,7 @@ func (c *client) Visit(url string) {
switch u.Scheme {
case "gopher":
if u.DownloadOnly {
nameSplit := strings.Split(u.Resource, "/")
filename := nameSplit[len(nameSplit)-1]
filename := path.Base(u.Resource)
filename = strings.Trim(filename, " \t\r\n\v\f\a")
if filename == "" {
filename = "gopherfile"
@ -943,8 +944,7 @@ func (c *client) Visit(url string) {
c.DrawMessage()
c.Draw()
case 'w':
nameSplit := strings.Split(u.Resource, "/")
filename := nameSplit[len(nameSplit)-1]
filename := path.Base(u.Resource)
c.saveFileFromData(capsule.Content, filename)
}
}
@ -1035,7 +1035,6 @@ func (c *client) ReloadPage() error {
return nil
}
//------------------------------------------------\\
// + + + F U N C T I O N S + + + \\
//--------------------------------------------------\\

View File

@ -23,6 +23,7 @@ import (
"io/ioutil"
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"
@ -61,7 +62,7 @@ func saveConfig() error {
opts.WriteString(certs)
return ioutil.WriteFile(bombadillo.Options["configlocation"]+"/.bombadillo.ini", []byte(opts.String()), 0644)
return ioutil.WriteFile(filepath.Join(bombadillo.Options["configlocation"], ".bombadillo.ini"), []byte(opts.String()), 0644)
}
func validateOpt(opt, val string) bool {