[gnome-shell] screenshot: Fix stripping suffix from relative filename



commit 4c6a0678fff5118880101211c84214fde61e9cb6
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jan 10 19:26:05 2020 +0100

    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 60278a8f3c..09f5c5109f 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),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]