Пример #1
0
        public MatchAccuracyMethod SelectsCorrectMatchAccuracyMethod(
            string urlSearch,
            MatchAccuracyMethod entryMam,
            MatchAccuracyMethod defaultMam,
            string[] overrideURLs = null,
            MatchAccuracyMethod[] overrideMethods = null)
        {
            var pwe  = new PwEntry(true, true);
            var conf = new EntryConfig(entryMam);

            pwe.SetKPRPCConfig(conf);
            var urlSummary = URLSummary.FromURL(urlSearch);
            var dbConf     = new DatabaseConfig()
            {
                DefaultMatchAccuracy = defaultMam
            };

            if (overrideURLs != null)
            {
                for (int i = 0; i < overrideURLs.Length; i++)
                {
                    dbConf.MatchedURLAccuracyOverrides.Add(overrideURLs[i], overrideMethods[i]);
                }
            }

            return(pwe.GetMatchAccuracyMethod(urlSummary, dbConf));
        }
Пример #2
0
        public void DataEndingWithFile()
        {
            var summary = URLSummary.FromURL("data:,_www.google.com.file://");

            Assert.AreEqual("", summary.HostnameAndPort);
            Assert.AreEqual("", summary.Port);
            Assert.IsNull(summary.Domain);
        }
Пример #3
0
        public void StandardHttpsWithPortAndPath()
        {
            var summary = URLSummary.FromURL("http://www.google.com:12345/any/path");

            Assert.AreEqual("www.google.com:12345", summary.HostnameAndPort);
            Assert.AreEqual("12345", summary.Port);
            Assert.AreEqual("google.com", summary.Domain.RegistrableDomain);
        }
Пример #4
0
        public void StandardData()
        {
            var summary = URLSummary.FromURL("data:,_www.google.com");

            Assert.AreEqual("", summary.HostnameAndPort);
            Assert.AreEqual("", summary.Port);
            Assert.IsNull(summary.Domain);
        }
Пример #5
0
        public void MalformedLocalFileWithExtension()
        {
            var summary = URLSummary.FromURL(@"c:\any\path\file.ext");

            Assert.AreEqual(@"c:\any\path\file.ext", summary.HostnameAndPort);
            Assert.AreEqual("", summary.Port);
            Assert.AreEqual("ext", summary.Domain.TLD);
        }
Пример #6
0
        public void MalformedLocalFileWithoutExtension()
        {
            var summary = URLSummary.FromURL(@"c:\any\path\file");

            Assert.AreEqual(@"c:\any\path\file", summary.HostnameAndPort);
            Assert.AreEqual("", summary.Port);
            Assert.IsNull(summary.Domain.RegistrableDomain);
        }
Пример #7
0
        public void StandardLocalFile()
        {
            var summary = URLSummary.FromURL("file://c/any/path/file.ext");

            Assert.AreEqual("c/any/path/file.ext", summary.HostnameAndPort);
            Assert.AreEqual("", summary.Port);
            Assert.IsNull(summary.Domain);
        }
Пример #8
0
        public void DataEndingWithQSAndHttps()
        {
            var summary = URLSummary.FromURL("data:,_www.google.com?anything.https://");

            Assert.AreEqual("", summary.HostnameAndPort);
            Assert.AreEqual("", summary.Port);
            Assert.IsNull(summary.Domain);
        }
Пример #9
0
        public void MalformedLocalFile()
        {
            var summary = URLSummary.FromURL(@"c:\any\path\file.ext");

            Assert.AreEqual(@"c:\any\path\file.ext", summary.HostnameAndPort);
            Assert.AreEqual("", summary.Port);
            Assert.IsNull(summary.Domain);
        }
Пример #10
0
        public MatchAccuracyEnum CalculatesCorrectMatchAccuracyScore(string urlEntry, string urlSearch, MatchAccuracyMethod entryMam)
        {
            var pwe = new PwEntry(true, true);

            pwe.Strings.Set("URL", new ProtectedString(false, urlEntry));
            var conf = new EntryConfig(entryMam);

            pwe.SetKPRPCConfig(conf);
            var urlSummary = URLSummary.FromURL(urlSearch);

            return((MatchAccuracyEnum)KeePassRPCService.BestMatchAccuracyForAnyURL(pwe, conf, urlSearch, urlSummary, entryMam));
        }