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

Commit

Permalink
Derive zip URL from template (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismwendt authored May 14, 2019
1 parent 2716762 commit a94fb11
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions buildserver/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package buildserver

import (
"context"
"fmt"
"io"
"io/ioutil"
"net/url"
"path"
"strings"

"github.com/pkg/errors"
Expand All @@ -26,8 +29,19 @@ var RemoteFS = func(ctx context.Context, initializeParams lspext.InitializeParam
if !ok {
return ""
}
url, _ := initializationOptions["zipURL"].(string)
return url
zipURL, _ := initializationOptions["zipURL"].(string)
if zipURL != "" {
return zipURL
}
zipURLTemplate, _ := initializationOptions["zipURLTemplate"].(string)
if zipURLTemplate == "" {
return ""
}
root, err := url.Parse(string(initializeParams.OriginalRootURI))
if err != nil {
return ""
}
return fmt.Sprintf(zipURLTemplate, path.Join(root.Host, root.Path), root.RawQuery)
}()
if zipURL != "" {
vfs, err := vfsutil.NewZipVFS(ctx, zipURL, zipFetch.Inc, zipFetchFailed.Inc, true)
Expand Down

0 comments on commit a94fb11

Please sign in to comment.