Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/sourcemaps/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,14 @@ func getAllSourceMapFiles(path string) ([]SourceMapFile, error) {
return err
}

name := filepath.ToSlash(relPath)
files = append(files, SourceMapFile{
Path: filePath,
Name: relPath,
Name: name,
})

routeGroupRemovedPath := routeGroupPattern.ReplaceAllString(relPath, "")
if routeGroupRemovedPath != relPath {
routeGroupRemovedPath := routeGroupPattern.ReplaceAllString(name, "")
if routeGroupRemovedPath != name {
files = append(files, SourceMapFile{
Path: filePath,
Name: routeGroupRemovedPath,
Expand Down
21 changes: 21 additions & 0 deletions cmd/sourcemaps/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/launchdarkly/ldcli/internal/analytics"
"github.com/launchdarkly/ldcli/internal/resources"
Expand Down Expand Up @@ -201,6 +202,26 @@ func TestGetAllSourceMapFiles(t *testing.T) {
assert.Contains(t, err.Error(), "no .js.map files found")
}

func TestGetAllSourceMapFilesRouteGroupKeys(t *testing.T) {
root := t.TempDir()
filePath := filepath.Join(root, "dist", "(dashboard)", "page.js.map")
require.NoError(t, os.MkdirAll(filepath.Dir(filePath), 0755))
require.NoError(t, os.WriteFile(filePath, []byte("{}"), 0644))

files, err := getAllSourceMapFiles(root)
require.NoError(t, err)

var keys []string
for _, file := range files {
assert.Equal(t, filePath, file.Path)
keys = append(keys, getS3Key("v1", "assets", file.Name))
}
assert.ElementsMatch(t, []string{
"v1/assets/dist/(dashboard)/page.js.map",
"v1/assets/dist/page.js.map",
}, keys)
}

func TestGetSourceMapUploadUrlsErrors(t *testing.T) {
_, err := getSourceMapUploadUrls("test-key", "project123", []string{"path"}, "://invalid-url")
assert.Error(t, err)
Expand Down
Loading