@xuda.io/drive_module 1.1.1317 → 1.1.1319

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.
Files changed (2) hide show
  1. package/index.mjs +24 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1246,6 +1246,7 @@ export const check_drive_file = async (req, job_id, headers, file_obj) => {
1246
1246
  type,
1247
1247
  file_path: path.dirname(file_path),
1248
1248
  stat: 3,
1249
+ uid,
1249
1250
  };
1250
1251
 
1251
1252
  if (type === 'file') {
@@ -2054,6 +2055,29 @@ export const update_drive_addons = async (req, job_id) => {
2054
2055
  return save_ret;
2055
2056
  };
2056
2057
 
2058
+ export const getExtensionFromUrl = function (imageUrl) {
2059
+ try {
2060
+ // Parse the URL to get the pathname
2061
+ const parsedUrl = new URL(imageUrl);
2062
+ const pathname = parsedUrl.pathname;
2063
+
2064
+ // Get extension from pathname
2065
+ const ext = path.extname(pathname);
2066
+
2067
+ // Remove the dot and convert to lowercase
2068
+ return ext ? ext.toLowerCase().slice(1) : '';
2069
+ } catch (error) {
2070
+ // If URL parsing fails, try to extract extension directly
2071
+ return getExtensionFromString(imageUrl);
2072
+ }
2073
+ };
2074
+
2075
+ function getExtensionFromString(str) {
2076
+ // Extract extension using regex
2077
+ const match = str.match(/\.([a-zA-Z0-9]+)(?:[?#].*)?$/);
2078
+ return match ? match[1].toLowerCase() : '';
2079
+ }
2080
+
2057
2081
  // Explicitly exporting dynamic functions for ESM compatibility
2058
2082
  export const get_drive_files_workspace = async (req, job_id, headers, file_obj) => {
2059
2083
  req.drive_type = 'workspace';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.1317",
3
+ "version": "1.1.1319",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {