From 4c6a0678fff5118880101211c84214fde61e9cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 10 Jan 2020 19:26:05 +0100 Subject: [PATCH] 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 --- js/ui/screenshot.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index 60278a8f3..09f5c5109 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -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),