private static Dictionary <string, NgProxyOptions> ParseOptions(IEnumerable <string> optionsList)
        {
            var pathPrefixToProxyOptionsMap = new Dictionary <string, NgProxyOptions>();

            // Parse the options strings.
            foreach (var optionsLine in optionsList)
            {
                var pathPrefix = GetNgServerBaseHref(optionsLine);
                // Path.StartsWithSegments() needs a pathPrefix without a trailing slash. Angular needs a trailing slash in baseHref.
                if (pathPrefix != "/")
                {
                    pathPrefix = pathPrefix.TrimEnd('/');
                }

                var proxyOptions = new NgProxyOptions
                {
                    Scheme = GetNgServerScheme(optionsLine),
                    Host   = GetNgServerHost(optionsLine),
                    Port   = GetNgServerPort(optionsLine),
                };

                pathPrefixToProxyOptionsMap.Add(pathPrefix, proxyOptions);
            }

            return(pathPrefixToProxyOptionsMap);
        }
Пример #2
0
 public NgProxy(NgProxyOptions options)
 {
     this.options    = options ?? throw new ArgumentNullException(nameof(options));
     this.httpClient = new HttpClient(new HttpClientHandler());
 }