@@ -50,7 +50,7 @@ function Url:is_org_link()
5050end
5151
5252function Url :is_file ()
53- return self .str :find (' ^file:' ) or self .str :find (' ^./' ) or self .str :find (' ^/' )
53+ return self .str :find (' ^file:' ) or self .str :find (' ^%.%./ ' ) or self . str : find ( ' ^% ./' ) or self .str :find (' ^/' )
5454end
5555
5656function Url :is_file_plain ()
7979function Url :extract_path ()
8080 local url = self
8181 if url :is_file_headline () or url :is_file_custom_id () then
82- return url .str :match (' ^file:([^:]-)::' ) or url .str :match (' ^(./[^:]-)::' ) or url .str :match (' ^(/[^:]-)::' )
82+ return url .str :match (' ^file:([^:]-)::' )
83+ or url .str :match (' ^(%.%./[^:]-)::' )
84+ or url .str :match (' ^(%./[^:]-)::' )
85+ or url .str :match (' ^(/[^:]-)::' )
8386 elseif url :is_file_line_number () then
84- return url .str :match (' ^file:([^:]-) %+' ) or url .str :match (' ^(./[^:]-) %+' ) or url .str :match (' ^(/[^:]-) %+' )
87+ return url .str :match (' ^file:([^:]-) %+' )
88+ or url .str :match (' ^(%.%./[^:]-) %+' )
89+ or url .str :match (' ^(%./[^:]-) %+' )
90+ or url .str :match (' ^(/[^:]-) %+' )
8591 elseif url :is_file_plain () then
86- return url .str :match (' ^file:([^:]-)$' ) or url .str :match (' ^(./[^:]-)$' ) or url .str :match (' ^(/[^:]-)$' )
92+ return url .str :match (' ^file:([^:]-)$' )
93+ or url .str :match (' ^(%.%./[^:]-)$' )
94+ or url .str :match (' ^(%./[^:]-)$' )
95+ or url .str :match (' ^(/[^:]-)$' )
8796 else
8897 return false
8998 end
98107--- @return string | false
99108function Url :get_headline ()
100109 return self .str :match (' ^file:[^:]+::%*(.-)$' )
101- or self .str :match (' ^./[^:]+::%*(.-)$' )
110+ or self .str :match (' ^%.%./[^:]+::%*(.-)$' )
111+ or self .str :match (' ^%./[^:]+::%*(.-)$' )
102112 or self .str :match (' ^/[^:]+::%*(.-)$' )
103113 or self .str :match (' ^%*(.-)$' )
104114end
105115
106116--- @return string | false
107117function Url :get_custom_id ()
108118 return self .str :match (' ^file:[^:]+::#(.-)$' )
109- or self .str :match (' ^./[^:]+::#(.-)$' )
119+ or self .str :match (' ^%.%./[^:]+::#(.-)$' )
120+ or self .str :match (' ^%./[^:]+::#(.-)$' )
110121 or self .str :match (' ^/[^:]+::#(.-)$' )
111122 or self .str :match (' ^#(.-)$' )
112123end
@@ -115,11 +126,13 @@ end
115126function Url :get_linenumber ()
116127 -- official orgmode convention
117128 return self .str :match (' ^file:[^:]+::(%d+)$' )
118- or self .str :match (' ^./[^:]+::(%d+)$' )
129+ or self .str :match (' ^%.%./[^:]+::(%d+)$' )
130+ or self .str :match (' ^%./[^:]+::(%d+)$' )
119131 or self .str :match (' ^/[^:]+::(%d+)$' )
120132 -- for backwards compatibility
121133 or self .str :match (' ^file:[^:]+ %+(%d+)$' )
122- or self .str :match (' ^./[^:]+ %+(%d+)$' )
134+ or self .str :match (' ^%.%./[^:]+ %+(%d+)$' )
135+ or self .str :match (' ^%./[^:]+ %+(%d+)$' )
123136 or self .str :match (' ^/[^:]+ %+(%d+)$' )
124137end
125138
@@ -128,15 +141,19 @@ function Url:get_filepath()
128141 return
129142 -- for backwards compatibility
130143 self .str :match (' ^file:([^:]+) %+%d+' )
144+ or self .str :match (' ^(%.%./[^:]+) %+%d+' )
131145 or self .str :match (' ^(%./[^:]+) %+%d+' )
132146 or self .str :match (' ^(/[^:]+) %+%d+' )
133147 -- official orgmode convention
134148 or self .str :match (' ^file:([^:]+)::' )
149+ or self .str :match (' ^(%.%./[^:]+)::' )
135150 or self .str :match (' ^(%./[^:]+)::' )
136151 or self .str :match (' ^(/[^:]+)::' )
137152 or self .str :match (' ^file:([^:]+)$' )
153+ or self .str :match (' ^(%.%./[^:]+)$' )
138154 or self .str :match (' ^(%./[^:]+)$' )
139155 or self .str :match (' ^(/[^:]+)$' )
156+ or self .str :match (' ^(%.%./)$' )
140157 or self .str :match (' ^(%./)$' )
141158 or self .str :match (' ^(/)$' )
142159end
0 commit comments