/** -------------------------------------------------------------------- **/ public void AddUrlQueueItem(string Url) { string NewUrl = Url; if (MacroscopePreferencesManager.GetIgnoreQueries()) { NewUrl = MacroscopeUrlUtils.StripQueryString(Url: NewUrl); } if (MacroscopePreferencesManager.GetIgnoreHashFragments()) { NewUrl = MacroscopeUrlUtils.StripHashFragment(Url: NewUrl); } if (!this.JobHistory.SeenHistoryItem(Url: NewUrl)) { try { MacroscopeJobItem JobItem; JobItem = new MacroscopeJobItem(Url: NewUrl); this.NamedQueueJobItems.AddToNamedQueue( Name: MacroscopeConstants.NamedQueueUrlList, Item: JobItem ); } catch (MacroscopeNamedQueueException ex) { this.DebugMsg(string.Format("AddUrlQueueItem: {0}", ex.Message)); } } this.AddToProgress(Url: NewUrl); }
public void TestStripHashFragment() { Dictionary <string, string> UrlList = new Dictionary <string, string> (); UrlList.Add("http://www.host.com/#aberdeen-angus", "http://www.host.com/"); UrlList.Add("http://www.host.com/product/list/#boris", "http://www.host.com/product/list/"); UrlList.Add("http://www.host.com/product/list/index.html#boris", "http://www.host.com/product/list/index.html"); UrlList.Add("http://www.host.com/?key1=value1&key2=value2&key3=value3", "http://www.host.com/?key1=value1&key2=value2&key3=value3"); UrlList.Add("http://www.host.com/?key1=value1&key2=value2&key3=value3#gonzo", "http://www.host.com/?key1=value1&key2=value2&key3=value3"); UrlList.Add("http://www.host.com/index.html?key1=value1&key2=value2&key3=value3#gonzo", "http://www.host.com/index.html?key1=value1&key2=value2&key3=value3"); foreach (string Url in UrlList.Keys) { string UrlResult = MacroscopeUrlUtils.StripHashFragment(Url); Assert.AreEqual(UrlList[Url], UrlResult, string.Format("NOT VALID: {0}", Url)); } }
/** -------------------------------------------------------------------- **/ public void ForgetUrlQueueItem(string Url) { MacroscopeJobItem JobItem; string NewUrl = Url; if (MacroscopePreferencesManager.GetIgnoreQueries()) { NewUrl = MacroscopeUrlUtils.StripQueryString(Url: NewUrl); } if (MacroscopePreferencesManager.GetIgnoreHashFragments()) { NewUrl = MacroscopeUrlUtils.StripHashFragment(Url: NewUrl); } JobItem = new MacroscopeJobItem(Url: NewUrl); this.NamedQueueJobItems.ForgetNamedQueueItem( Name: MacroscopeConstants.NamedQueueUrlList, Item: JobItem ); }