screenshot: Fix stripping suffix from relative filename

String.prototype.substr() doesn't support a negative length value
(to subtract from the full length), so we end up with a filename
of '' when hitting that code paths (a relative filename with '.png'
suffix).

Fix this by switching to String.prototype.replace() instead.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/2091
This commit is contained in:
Florian Müllner 2020-01-10 19:26:05 +01:00
parent a8dcfa4656
commit 4c6a0678ff

View File

@ -65,8 +65,7 @@ var ScreenshotService = class {
}
*_resolveRelativeFilename(filename) {
if (GLib.str_has_suffix(filename, '.png'))
filename = filename.substr(0, -4);
filename = filename.replace(/\.png$/, '');
let path = [
GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES),