public void ShouldGetResourceLocation() { var wrappedUrl = "http://goo.gl/mSkqOi"; var subject = new WebClientUrlUnwrapper(); WebClientUrlUnwrapper.ResolveUrls = true; var directUrl = subject.GetDirectUrl(wrappedUrl); directUrl.Should().Be("http://example.com/"); WebClientUrlUnwrapper.ResolveUrls = false; }
public void ShouldReturnGivenLocationIfAuthenticationRequired() { var givenUrl = "http://durwella.com/testing/does-not-exist"; var subject = new WebClientUrlUnwrapper { IgnoreErrorCodes = new[] { HttpStatusCode.NotFound } }; WebClientUrlUnwrapper.ResolveUrls = true; var directUrl = subject.GetDirectUrl(givenUrl); directUrl.Should().Be(givenUrl); WebClientUrlUnwrapper.ResolveUrls = false; }
private void SetupUrlShortening(Container container) { container.Register <IResolver>(container); var aliasRepository = SetupAzureStorageAliasRepository() ?? new MemoryAliasRepository(); container.Register(aliasRepository); container.Register <IProtectedPathList>(this); SetupPreferredHashLength(container); var ignoreErrorCodesString = ConfigurationManager.AppSettings["IgnoreErrorCodes"]; if (!ignoreErrorCodesString.IsNullOrEmpty()) { var ignoreErrorCodes = ignoreErrorCodesString.Split(',', ' ') .Select(s => (HttpStatusCode)Convert.ToInt32(s)).ToList(); var urlUnwrapper = new WebClientUrlUnwrapper { IgnoreErrorCodes = ignoreErrorCodes }; container.Register <IUrlUnwrapper>(urlUnwrapper); } WebClientUrlUnwrapper.ResolveUrls = ConfigurationManager.AppSettings["ResolveUrls"].ToLower() == "true"; }