Skip to content

Commit 41a3ad3

Browse files
author
Max Schaefer
committed
JavaScript: Tweak some regexes in Files.qll.
It seems preferable to use the same regex everywhere, even if it's overly general for a few cases.
1 parent f5279b2 commit 41a3ad3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

javascript/ql/src/semmle/javascript/Files.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ abstract class Container extends @container {
7575
* </table>
7676
*/
7777
string getBaseName() {
78-
result = getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
78+
result = getAbsolutePath().regexpCapture(".*/(([^/]*?)(\\.([^.]*))?)", 1)
7979
}
8080

8181
/**
@@ -101,7 +101,7 @@ abstract class Container extends @container {
101101
* <tr><td>"/tmp/x.tar.gz"</td><td>"gz"</td></tr>
102102
* </table>
103103
*/
104-
string getExtension() { result = getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3) }
104+
string getExtension() { result = getAbsolutePath().regexpCapture(".*/(([^/]*?)(\\.([^.]*))?)", 4) }
105105

106106
/**
107107
* Gets the stem of this container, that is, the prefix of its base name up to
@@ -120,7 +120,7 @@ abstract class Container extends @container {
120120
* <tr><td>"/tmp/x.tar.gz"</td><td>"x.tar"</td></tr>
121121
* </table>
122122
*/
123-
string getStem() { result = getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1) }
123+
string getStem() { result = getAbsolutePath().regexpCapture(".*/(([^/]*?)(\\.([^.]*))?)", 2) }
124124

125125
/** Gets the parent container of this file or folder, if any. */
126126
Container getParentContainer() { containerparent(result, this) }

0 commit comments

Comments
 (0)