@xuda.io/drive_module 1.1.1317 → 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 +23 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2054,6 +2054,29 @@ export const update_drive_addons = async (req, job_id) => {
2054
2054
  return save_ret;
2055
2055
  };
2056
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
+
2057
2080
  // Explicitly exporting dynamic functions for ESM compatibility
2058
2081
  export const get_drive_files_workspace = async (req, job_id, headers, file_obj) => {
2059
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.1317",
3
+ "version": "1.1.1318",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {