We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3bc198 commit 4491e47Copy full SHA for 4491e47
1 file changed
lib/util/url.js
@@ -69,11 +69,25 @@ exports.getProtocol = function getProtocol (path) {
69
exports.getExtension = function getExtension (path) {
70
let lastDot = path.lastIndexOf(".");
71
if (lastDot >= 0) {
72
- return path.substr(lastDot).toLowerCase();
+ return url.stripQuery(path.substr(lastDot).toLowerCase());
73
}
74
return "";
75
};
76
77
+/**
78
+ * Removes the query, if any, from the given path.
79
+ *
80
+ * @param {string} path
81
+ * @returns {string}
82
+ */
83
+exports.stripQuery = function stripQuery (path) {
84
+ let queryIndex = path.indexOf("?");
85
+ if (queryIndex >= 0) {
86
+ path = path.substr(0, queryIndex);
87
+ }
88
+ return path;
89
+};
90
+
91
/**
92
* Returns the hash (URL fragment), of the given path.
93
* If there is no hash, then the root hash ("#") is returned.
0 commit comments