@lijuhong1981/jsurl 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/extractBaseName.js +6 -11
- package/src/extractExtName.js +5 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lijuhong1981/jsurl",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "lijuhong1981 <lijuhong@hotmail.com>",
|
|
6
6
|
"homepage": "https://github.com/lijuhong1981/jslibs#readme",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/lijuhong1981/jslibs/issues"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "8c4290de1f254bd1d048e243b9fcaf61e777f638"
|
|
22
22
|
}
|
package/src/extractBaseName.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
+
import extractFileName from "./extractFileName.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 从url中提取不包含扩展名的文件名
|
|
3
5
|
* @param {String} url 传入的url
|
|
4
6
|
* @returns {String} 提取的文件名
|
|
5
7
|
*/
|
|
6
8
|
function extractBaseName(url) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
url = url.substring(0, index);
|
|
10
|
-
|
|
11
|
-
index = url.lastIndexOf('.');
|
|
12
|
-
if (index !== -1)
|
|
13
|
-
url = url.substring(0, index);
|
|
14
|
-
|
|
15
|
-
index = url.lastIndexOf('/');
|
|
9
|
+
const fileName = extractFileName(url);
|
|
10
|
+
const index = fileName.lastIndexOf('.');
|
|
16
11
|
if (index === -1)
|
|
17
|
-
return
|
|
18
|
-
return
|
|
12
|
+
return fileName;
|
|
13
|
+
return fileName.substring(0, index);
|
|
19
14
|
};
|
|
20
15
|
|
|
21
16
|
export default extractBaseName;
|
package/src/extractExtName.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import extractFileName from "./extractFileName.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 从url中提取文件扩展名
|
|
3
5
|
* @param {String} url 传入的url
|
|
@@ -5,14 +7,11 @@
|
|
|
5
7
|
* @returns {String} 提取的扩展名
|
|
6
8
|
*/
|
|
7
9
|
function extractExtName(url, containsPoint = true) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
url = url.substring(0, index);
|
|
11
|
-
|
|
12
|
-
index = url.lastIndexOf('.');
|
|
10
|
+
const fileName = extractFileName(url);
|
|
11
|
+
const index = fileName.lastIndexOf('.');
|
|
13
12
|
if (index === -1)
|
|
14
13
|
return '';
|
|
15
|
-
return
|
|
14
|
+
return fileName.substring(containsPoint ? index : index + 1);
|
|
16
15
|
};
|
|
17
16
|
|
|
18
17
|
export default extractExtName;
|