contrib/sort_downloads: fix replace_tilde
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 6 Aug 2013 15:59:28 +0000 (11:59 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 6 Aug 2013 15:59:28 +0000 (11:59 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/sort_downloads/src/sort_downloads.nit

index c1d2568..b3ae759 100755 (executable)
@@ -68,8 +68,11 @@ redef class String
        # Replace `~` by the path to the home diretory
        fun replace_tilde: String
        do
-               var home_folder = "HOME".environ
-               return replace("~", home_folder)
+               var match = search("~/")
+               if match != null and match.from == 0 then
+                       var home_folder = "HOME".environ
+                       return "{home_folder}/{substring(match.after, length)}"
+               else return self
        end
 end