zumoshi / BrowserSelect

Browser Select is a utility to dynamically select the browser you want instead of just having one default for all links.
GNU General Public License v2.0
289 stars 39 forks source link

matching on urls rather than domains only #67

Open JaspalX opened 4 years ago

JaspalX commented 4 years ago

I've had a look at the code but as I mentioned - unfamiliar with c# - if you can help me log/debug the url matching code I reckon I could work it out - at the moment I can't 'see' what parameters are being passed into the regex check in DoesWildcardMatch (and DoesDomainMatchPattern) even when I break drop the scheme from the uri (uri.host+uri.pathandquery+uri.fragment) - I guess there may be some escaping but not sure :(

same domain but different url

That is unrelated to this issue, please open a new one. But in short, the wildcard is already supported, (e.g. *.whatever.com), You just need to include the path in the string the rules are checked against. Somewhere around here. Check the Uri Class documentation for properties other than Host to check. The tricky part would be to make sure it won't break domain-only rules if say the domain name existed somewhere in the url's path. (e.g. something.com/link/somethingelse.com/ )

Originally posted by @zumoshi in https://github.com/zumoshi/BrowserSelect/issues/61#issuecomment-647096584

zumoshi commented 4 years ago

uri.host+uri.pathandquery+uri.fragment

image

Keep in mind that the method only checks for exact matches, as in nothing that isn't wildcarded shouldn't be left or it won't match: image

Hence why I said it might be tricky to add this feature without breaking existing domain-only rules or changing the UI to allow different rule types to be added.

may be some escaping

Only for non-ASCII characters or spaces. e.g. a.com/what ever => a.com/what%20ever a.com/متن-غیر-انگلیسی => a.com/%D9%85%D8%AA%D9%86-%D8%BA%DB%8C%D8%B1-%D8%A7%D9%86%DA%AF%D9%84%DB%8C%D8%B3%DB%8C

help me log/debug the url

Best way is to set some breakpoints and step through the code.

JaspalX commented 4 years ago

Thanks. I get Settings.Default.AutoBrowser is null when launching to debug with an argument - is that a bug?

zumoshi commented 4 years ago

Settings.Default.AutoBrowser is null

Did you make any rules? Debug mode settings may be stored separately from the installed version. Try adding some rules when launching as debug then restarting the app and checking its value.

JaspalX commented 4 years ago

Mate, whichever file I try to run I see null in autobrowser regardless of whether I've set a rule or not. the rules are being saved between runs and are separate to the installed version. should I be running browser.cs or program.cs?  any ideas to help getting it running? thanks On 21/06/2020 23:03:06, Borhan Hafez notifications@github.com wrote: Settings.Default.AutoBrowser is null Did you make any rules? Debug mode settings may be stored separately from the installed version. Try adding some rules when launching as debug then restarting the app and checking it's value. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [https://github.com/zumoshi/BrowserSelect/issues/67#issuecomment-647187532], or unsubscribe [https://github.com/notifications/unsubscribe-auth/AANQOL6M2T3TS2N7TMAC3GDRXZ7RVANCNFSM4OD2IOCQ].

zumoshi commented 4 years ago

I don't run files individually, if you open BrowserSelect.sln in Visual Studio it should recognize the project and allow you to debug the whole thing. Depending on what IDE you use you may be able to load BrowserSelect.csproj instead, which is an XML file including a list of all the dependencies and files required for the project to function.

Alternatively, you can manually verify if the options are saved or not by looking at the path it should save them in. You can find this path programmatically by running:

var path = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath;

(you may need some imports/references for it to work)

On my system that path is:

C:\Users\Bor\AppData\Local\BrowserSelect\BrowserSelect.exe_Url_1aa1pcucfjv1jpsasunq3pmxflnpikth\1.4.1.0\user.config

The hash-style part may be different for you, but it should stay the same between builds using the same system/ide. Try checking the file's content or manually copying your normal config overwriting the one debug instance uses. Sometimes when debugging the first part may be BrowserSelect.vshost.exe instead of BrowserSelect.exe.

image Example of Settings.Default.AutoBrowser getting its value from the config file.

Hope this helps.

JaspalX commented 4 years ago

got it, thanks. it seems on at least the first pass through the loop at line 55 the autobrowser is null...I can sort of ignore that by setting my breakpoint at line 65. On 25/06/2020 16:14:27, Borhan Hafez notifications@github.com wrote: I don't run files individually, if you open BrowserSelect.sln in Visual Studio it should recognize the project and allow you to debug the whole thing. Depending on what IDE you use you may be able to load BrowserSelect.csproj instead, which is an XML file including a list of all the dependencies and files required for the project to function. Alternatively, you can manually verify if the options are saved or not by looking at the path it should save them in. You can find this path programmatically by running: var path = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath; (you may need some imports/references [https://stackoverflow.com/a/7069366/1461004] for it to work) On my system that path is: C:\Users\Bor\AppData\Local\BrowserSelect\BrowserSelect.exe_Url_1aa1pcucfjv1jpsasunq3pmxflnpikth\1.4.1.0\user.config The hash-style part may be different for you, but it should stay the same between builds using the same system/ide. Try checking the file's content or manually copying your normal config overwriting the one debug instance uses. Sometimes when debugging the first part may be BrowserSelect.vshost.exe instead of BrowserSelect.exe. [image] [https://user-images.githubusercontent.com/4184939/85746848-04758780-b71c-11ea-9db3-705218e7e63a.png] Example of Settings.Default.AutoBrowser getting its value from the config file. Hope this helps. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [https://github.com/zumoshi/BrowserSelect/issues/67#issuecomment-649613905], or unsubscribe [https://github.com/notifications/unsubscribe-auth/AANQOL6PTZROCLKWY5MKFN3RYNSVHANCNFSM4OD2IOCQ].