Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit a94fb11

Browse files
authored
Derive zip URL from template (#370)
1 parent 2716762 commit a94fb11

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

buildserver/vfs.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ package buildserver
22

33
import (
44
"context"
5+
"fmt"
56
"io"
67
"io/ioutil"
8+
"net/url"
9+
"path"
710
"strings"
811

912
"github.com/pkg/errors"
@@ -26,8 +29,19 @@ var RemoteFS = func(ctx context.Context, initializeParams lspext.InitializeParam
2629
if !ok {
2730
return ""
2831
}
29-
url, _ := initializationOptions["zipURL"].(string)
30-
return url
32+
zipURL, _ := initializationOptions["zipURL"].(string)
33+
if zipURL != "" {
34+
return zipURL
35+
}
36+
zipURLTemplate, _ := initializationOptions["zipURLTemplate"].(string)
37+
if zipURLTemplate == "" {
38+
return ""
39+
}
40+
root, err := url.Parse(string(initializeParams.OriginalRootURI))
41+
if err != nil {
42+
return ""
43+
}
44+
return fmt.Sprintf(zipURLTemplate, path.Join(root.Host, root.Path), root.RawQuery)
3145
}()
3246
if zipURL != "" {
3347
vfs, err := vfsutil.NewZipVFS(ctx, zipURL, zipFetch.Inc, zipFetchFailed.Inc, true)

0 commit comments

Comments
 (0)