Commit 9e9319e
committed
misc/path_utils: make mp_basename() return full URLs
When the path is a URL, use the whole path as basename. The dirname will
be "." in this case.
This simplifies various checks throughout the codebase. In particular,
it avoids returning an empty string for URLs ending with /.
The filename property will return full URLs, which is desirable because
the domain and path segments before the last are useful information.
This fixes half of mpv-player#10975. The empty string check in
mp_property_filename() can be removed because it only happened with the
basename of URLs ending with /. mp_property_filename() will not be
called with directories with trailing slashes because mpv expands them
immediately when they are the current playlist entry; I tested it by
observing filename. Also mpv-player#16896 will prevent directories with trailing
slashes anyway.
This also fixes the issue described in mpv-player#17015 of %f in
--screenshot-template being evaluated to an empty string for URLs ending
with /, which can inadvertently make it use an absolute path.
Alternative to mpv-player#16932 and mpv-player#17021.1 parent bbafb74 commit 9e9319e
File tree
4 files changed
+18
-27
lines changed- misc
- player
- lua
4 files changed
+18
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | | - | |
531 | | - | |
532 | 530 | | |
533 | 531 | | |
534 | 532 | | |
| |||
3508 | 3506 | | |
3509 | 3507 | | |
3510 | 3508 | | |
3511 | | - | |
3512 | | - | |
3513 | | - | |
3514 | | - | |
3515 | | - | |
3516 | | - | |
| 3509 | + | |
| 3510 | + | |
| 3511 | + | |
3517 | 3512 | | |
3518 | 3513 | | |
3519 | 3514 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
219 | | - | |
220 | | - | |
| 218 | + | |
221 | 219 | | |
222 | 220 | | |
223 | 221 | | |
| |||
255 | 253 | | |
256 | 254 | | |
257 | 255 | | |
258 | | - | |
| 256 | + | |
259 | 257 | | |
260 | 258 | | |
261 | 259 | | |
| |||
287 | 285 | | |
288 | 286 | | |
289 | 287 | | |
290 | | - | |
| 288 | + | |
291 | 289 | | |
292 | 290 | | |
293 | 291 | | |
| |||
412 | 410 | | |
413 | 411 | | |
414 | 412 | | |
415 | | - | |
| 413 | + | |
416 | 414 | | |
417 | 415 | | |
418 | 416 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 52 | + | |
| 53 | + | |
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
| |||
0 commit comments