MCPcopy
hub / github.com/wavetermdev/waveterm / ParseURIAndReplaceCurrentHost

Function ParseURIAndReplaceCurrentHost

pkg/remote/connparse/connparse.go:65–83  ·  view source on GitHub ↗
(ctx context.Context, uri string)

Source from the content-addressed store, hash-verified

63}
64
65func ParseURIAndReplaceCurrentHost(ctx context.Context, uri string) (*Connection, error) {
66 conn, err := ParseURI(uri)
67 if err != nil {
68 return nil, fmt.Errorf("error parsing connection: %v", err)
69 }
70 if conn.Host == ConnHostCurrent {
71 source, err := GetConnNameFromContext(ctx)
72 if err != nil {
73 return nil, fmt.Errorf("error getting connection name from context: %v", err)
74 }
75
76 // RPC context connection is empty for local connections
77 if source == "" {
78 source = wshrpc.LocalConnName
79 }
80 conn.Host = source
81 }
82 return conn, nil
83}
84
85func GetConnNameFromContext(ctx context.Context) (string, error) {
86 handler := wshutil.GetRpcResponseHandlerFromContext(ctx)

Callers 3

RemoteFileCopyCommandMethod · 0.92
RemoteFileMoveCommandMethod · 0.92
parseConnectionFunction · 0.92

Calls 2

ParseURIFunction · 0.85
GetConnNameFromContextFunction · 0.85

Tested by

no test coverage detected