From 539e2a4ca649263fdcf99271d972ce3a21f09ed9 Mon Sep 17 00:00:00 2001 From: Javier Albornoz Date: Thu, 3 Aug 2017 10:30:23 -0600 Subject: [PATCH] Parse the filename correctly Remove the URL query parameters before extracting the filename from the URL. If the URL query parameters contain slashes, when the function split the URL string, it got the filename wrongly. Therefore, the syntax highligthing does not work properly. For example: https://gerrit.example.com/path/to/file.c?h=branch/name was returning "name" as filename, when the expected output is "file.c". Signed-off-by: Javier Albornoz --- js/background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/background.js b/js/background.js index 6192283..00a2c7a 100644 --- a/js/background.js +++ b/js/background.js @@ -114,7 +114,7 @@ } function getFilenameFromUrl(url) { - return url.split('/').pop().split('?').shift().toLowerCase(); + return url.split('?').shift().split('/').pop().toLowerCase(); } function getExtensionFromFilename(filename) {