Merge pull request #680 from harshavardhana/pr_out_on_windows_display_directories_with_forward_slash_and_also_interpret_prefixes
This commit is contained in:
+2
-1
@@ -66,7 +66,8 @@ func aliasExpand(aliasedURL string, aliases map[string]string) (newURL string, e
|
||||
// if more splits found return
|
||||
if len(splits) == 2 {
|
||||
// remove any prefixed slashes
|
||||
u, err := client.Parse(expandedURL + "/" + strings.TrimPrefix(splits[1], "/"))
|
||||
trimmedURL := expandedURL + "/" + strings.TrimPrefix(strings.TrimPrefix(splits[1], "/"), "\\")
|
||||
u, err := client.Parse(trimmedURL)
|
||||
if err != nil {
|
||||
return aliasedURL, iodine.New(errInvalidURL{url: aliasedURL}, nil)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
@@ -45,7 +46,11 @@ func printContent(c *client.Content) {
|
||||
return "application/octet-stream"
|
||||
}()
|
||||
content.Size = humanize.IBytes(uint64(c.Size))
|
||||
content.Name = strings.TrimSuffix(c.Name, "/")
|
||||
if runtime.GOOS == "windows" {
|
||||
content.Name = strings.Replace(c.Name, "/", "\\", -1)
|
||||
content.Name = strings.TrimSuffix(content.Name, "\\")
|
||||
}
|
||||
content.Name = strings.TrimSuffix(content.Name, "/")
|
||||
content.Time = c.Time.Local().Format(printDate)
|
||||
console.ContentInfo(content)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"path/filepath"
|
||||
@@ -254,7 +255,7 @@ var (
|
||||
// special cases only for Content where it requires custom formatting
|
||||
case themesDB[currThemeName].Time:
|
||||
mutex.Lock()
|
||||
c.Print(fmt.Sprintf("[%s]", a...))
|
||||
c.Print(fmt.Sprintf("[%s] ", a...))
|
||||
mutex.Unlock()
|
||||
case themesDB[currThemeName].Size:
|
||||
mutex.Lock()
|
||||
@@ -301,8 +302,12 @@ var (
|
||||
mutex.Unlock()
|
||||
case themesDB[currThemeName].Dir:
|
||||
mutex.Lock()
|
||||
// ugly but its needed
|
||||
c.Printf("%s/\n", a...)
|
||||
switch {
|
||||
case runtime.GOOS == "windows":
|
||||
c.Printf("%s\\\n", a...)
|
||||
default:
|
||||
c.Printf("%s/\n", a...)
|
||||
}
|
||||
mutex.Unlock()
|
||||
case themesDB[currThemeName].File:
|
||||
mutex.Lock()
|
||||
|
||||
Reference in New Issue
Block a user