[tomboy] Watchers.cs: add URL regex for Win-style paths we insert on drag'n'drop



commit 3b61ca4da9c67081d6dcb79d0f294ec6a9e7ffb8
Author: Alex Tereschenko <frozen and blue gmail com>
Date:   Sun Dec 4 18:17:09 2016 +0100

    Watchers.cs: add URL regex for Win-style paths we insert on drag'n'drop
    
    We will now properly highlight and open URLs produced by dragging
    and dropping a file or directory on Windows.
    
    Fixes #22.
    
    Signed-off-by: Alex Tereschenko <frozen and blue gmail com>

 Tomboy/Watchers.cs |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/Tomboy/Watchers.cs b/Tomboy/Watchers.cs
index c2625f9..67d5c44 100644
--- a/Tomboy/Watchers.cs
+++ b/Tomboy/Watchers.cs
@@ -418,6 +418,7 @@ namespace Tomboy
                                    @"("+
                                            @"(/\S+/)"+                         // or starting with '/'
                                            @"|(~/\S+?)"+                               // or starting with 
'~/'
+                                           @"|(\p{L}{1}:%5C\S+?)"+             // or starting with something 
like "C:\"
                                    @")"+
                                @"))"+
                                @"(?(starter)"+                     //
@@ -487,7 +488,7 @@ namespace Tomboy
 
                        // Simple url massaging.  Add to 'http://' to the front
                        // of www.foo.com, 'mailto:' to alex foo com, 'file://'
-                       // to /home/alex/foo.
+                       // to /home/alex/foo, 'file:///' to C:\my\file.
                        if (url.StartsWith ("www."))
                                url = "http://"; + url;
                        else if (url.StartsWith ("/") &&
@@ -501,6 +502,9 @@ namespace Tomboy
                                @"^(?!(news|mailto|http|https|ftp|file|irc):).+@.{2,}$",
                                RegexOptions.IgnoreCase))
                                url = "mailto:"; + url;
+                       else if (Regex.IsMatch (url,
+                               @"^\p{L}{1}:%5C\S+?"))
+                               url = "file:///" + url;
 
                        return url;
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]