From: Scott Worley Date: Fri, 28 Feb 2014 17:32:51 +0000 (-0800) Subject: I miss ${foo%bar} X-Git-Url: http://git.scottworley.com/picsort/commitdiff_plain/8bc0aad4edd7e9d033870594f833b24af6a108e1?hp=fd69f56988c764cf5b190f130ecbe365de64b8ca I miss ${foo%bar} --- diff --git a/picsorter.js b/picsorter.js index 70cd236..2f9df0c 100644 --- a/picsorter.js +++ b/picsorter.js @@ -16,6 +16,16 @@ var exposure = 20; var zoom = "sm/"; var input_index = -1; +function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; +} + +function stripFromEnd(str, suffix) { + if (endsWith(str, suffix)) { + return str.substr(0, str.length - suffix.length); + } + return str; +} function setpic() { if ("exposure" in picinfo[files[input_index]]) {