Correctly handle Windows paths when creating gists

This commit is contained in:
Josh Gross 2022-02-06 23:21:20 +00:00 committed by GitHub
parent 4f0264e37b
commit f43574bfe0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -8,7 +8,7 @@ import (
"io"
"io/ioutil"
"net/http"
"path"
"path/filepath"
"regexp"
"sort"
"strings"
@ -215,7 +215,7 @@ func processFiles(stdin io.ReadCloser, filenameOverride string, filenames []stri
return fs, fmt.Errorf("failed to read file %s: %w", f, err)
}
filename = path.Base(f)
filename = filepath.Base(f)
}
fs[filename] = &shared.GistFile{

View file

@ -5,7 +5,7 @@ import (
"encoding/json"
"io/ioutil"
"net/http"
"path"
"path/filepath"
"strings"
"testing"
@ -163,9 +163,9 @@ func TestNewCmdCreate(t *testing.T) {
func Test_createRun(t *testing.T) {
tempDir := t.TempDir()
fixtureFile := path.Join(tempDir, "fixture.txt")
fixtureFile := filepath.Join(tempDir, "fixture.txt")
assert.NoError(t, ioutil.WriteFile(fixtureFile, []byte("{}"), 0644))
emptyFile := path.Join(tempDir, "empty.txt")
emptyFile := filepath.Join(tempDir, "empty.txt")
assert.NoError(t, ioutil.WriteFile(emptyFile, []byte(" \t\n"), 0644))
tests := []struct {