@@ -50,7 +50,7 @@ function Url:is_org_link()
50
50
end
51
51
52
52
function 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 (' ^/' )
54
54
end
55
55
56
56
function Url :is_file_plain ()
79
79
function Url :extract_path ()
80
80
local url = self
81
81
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 (' ^(/[^:]-)::' )
83
86
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 (' ^(/[^:]-) %+' )
85
91
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 (' ^(/[^:]-)$' )
87
96
else
88
97
return false
89
98
end
98
107
--- @return string | false
99
108
function Url :get_headline ()
100
109
return self .str :match (' ^file:[^:]+::%*(.-)$' )
101
- or self .str :match (' ^./[^:]+::%*(.-)$' )
110
+ or self .str :match (' ^%.%./[^:]+::%*(.-)$' )
111
+ or self .str :match (' ^%./[^:]+::%*(.-)$' )
102
112
or self .str :match (' ^/[^:]+::%*(.-)$' )
103
113
or self .str :match (' ^%*(.-)$' )
104
114
end
105
115
106
116
--- @return string | false
107
117
function Url :get_custom_id ()
108
118
return self .str :match (' ^file:[^:]+::#(.-)$' )
109
- or self .str :match (' ^./[^:]+::#(.-)$' )
119
+ or self .str :match (' ^%.%./[^:]+::#(.-)$' )
120
+ or self .str :match (' ^%./[^:]+::#(.-)$' )
110
121
or self .str :match (' ^/[^:]+::#(.-)$' )
111
122
or self .str :match (' ^#(.-)$' )
112
123
end
@@ -115,11 +126,13 @@ end
115
126
function Url :get_linenumber ()
116
127
-- official orgmode convention
117
128
return self .str :match (' ^file:[^:]+::(%d+)$' )
118
- or self .str :match (' ^./[^:]+::(%d+)$' )
129
+ or self .str :match (' ^%.%./[^:]+::(%d+)$' )
130
+ or self .str :match (' ^%./[^:]+::(%d+)$' )
119
131
or self .str :match (' ^/[^:]+::(%d+)$' )
120
132
-- for backwards compatibility
121
133
or self .str :match (' ^file:[^:]+ %+(%d+)$' )
122
- or self .str :match (' ^./[^:]+ %+(%d+)$' )
134
+ or self .str :match (' ^%.%./[^:]+ %+(%d+)$' )
135
+ or self .str :match (' ^%./[^:]+ %+(%d+)$' )
123
136
or self .str :match (' ^/[^:]+ %+(%d+)$' )
124
137
end
125
138
@@ -128,15 +141,19 @@ function Url:get_filepath()
128
141
return
129
142
-- for backwards compatibility
130
143
self .str :match (' ^file:([^:]+) %+%d+' )
144
+ or self .str :match (' ^(%.%./[^:]+) %+%d+' )
131
145
or self .str :match (' ^(%./[^:]+) %+%d+' )
132
146
or self .str :match (' ^(/[^:]+) %+%d+' )
133
147
-- official orgmode convention
134
148
or self .str :match (' ^file:([^:]+)::' )
149
+ or self .str :match (' ^(%.%./[^:]+)::' )
135
150
or self .str :match (' ^(%./[^:]+)::' )
136
151
or self .str :match (' ^(/[^:]+)::' )
137
152
or self .str :match (' ^file:([^:]+)$' )
153
+ or self .str :match (' ^(%.%./[^:]+)$' )
138
154
or self .str :match (' ^(%./[^:]+)$' )
139
155
or self .str :match (' ^(/[^:]+)$' )
156
+ or self .str :match (' ^(%.%./)$' )
140
157
or self .str :match (' ^(%./)$' )
141
158
or self .str :match (' ^(/)$' )
142
159
end
0 commit comments