@xuda.io/drive_module 1.1.1316 → 1.1.1318

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
@@ -488,6 +488,7 @@ export const delete_drive_files = async (req, job_id, headers) => {
488
488
  }
489
489
 
490
490
  if (doc.type === 'directory') {
491
+ debugger;
491
492
  const files_in_directory = await get_folder_files(uid, app_id, drive_type, path.join(doc.file_path, doc.folder_name));
492
493
  if (files_in_directory?.length) {
493
494
  throw new Error(`Directory is not empty`);
@@ -2053,6 +2054,29 @@ export const update_drive_addons = async (req, job_id) => {
2053
2054
  return save_ret;
2054
2055
  };
2055
2056
 
2057
+ export const getExtensionFromUrl = function (imageUrl) {
2058
+ try {
2059
+ // Parse the URL to get the pathname
2060
+ const parsedUrl = new URL(imageUrl);
2061
+ const pathname = parsedUrl.pathname;
2062
+
2063
+ // Get extension from pathname
2064
+ const ext = path.extname(pathname);
2065
+
2066
+ // Remove the dot and convert to lowercase
2067
+ return ext ? ext.toLowerCase().slice(1) : '';
2068
+ } catch (error) {
2069
+ // If URL parsing fails, try to extract extension directly
2070
+ return getExtensionFromString(imageUrl);
2071
+ }
2072
+ };
2073
+
2074
+ function getExtensionFromString(str) {
2075
+ // Extract extension using regex
2076
+ const match = str.match(/\.([a-zA-Z0-9]+)(?:[?#].*)?$/);
2077
+ return match ? match[1].toLowerCase() : '';
2078
+ }
2079
+
2056
2080
  // Explicitly exporting dynamic functions for ESM compatibility
2057
2081
  export const get_drive_files_workspace = async (req, job_id, headers, file_obj) => {
2058
2082
  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.1316",
3
+ "version": "1.1.1318",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {