@lrnwebcomponents/utils
Advanced tools
Comparing version 7.0.18 to 8.0.0
@@ -40,2 +40,6 @@ export const remoteLinkBehavior = function (SuperClass) { | ||
} | ||
else if (target) { | ||
target.removeAttribute("target"); | ||
target.removeAttribute("rel"); | ||
} | ||
} | ||
@@ -42,0 +46,0 @@ /** |
{ | ||
"name": "@lrnwebcomponents/utils", | ||
"version": "7.0.18", | ||
"version": "8.0.0", | ||
"description": "Helper functions to clean up web component data handling.", | ||
@@ -20,3 +20,3 @@ "repository": { | ||
}, | ||
"gitHead": "b9873176f9fe50a77dcf25e44bf3450d26fbb37a" | ||
"gitHead": "2791492ff7ab40c7d4c827c4b305e33c0a971230" | ||
} |
54
utils.js
@@ -197,2 +197,47 @@ /** | ||
// convert mimetype into a readable file extension | ||
export function mimeTypeToName(mimeType) { | ||
let data = mimeType.split('/'); | ||
switch (data[1]) { | ||
case 'msword': | ||
return '.doc'; | ||
case 'application/vnd.ms-excel': | ||
return '.xls'; | ||
case 'vnd.ms-powerpoint': | ||
return '.ppt'; | ||
case 'vnd.openxmlformats-officedocument.wordprocessingml.document': | ||
return '.docx'; | ||
case 'vnd.openxmlformats-officedocument.spreadsheetml.sheet': | ||
return '.xlsx'; | ||
case 'vnd.openxmlformats-officedocument.presentationml.presentation': | ||
return '.pptx'; | ||
case 'mpeg': | ||
return '.mp3'; | ||
case 'svg+xml': | ||
return '.svg'; | ||
case 'markdown': | ||
return '.md'; | ||
case 'plain': | ||
return 'text'; | ||
case 'text': | ||
return '.txt'; | ||
case 'rtf': | ||
case 'gif': | ||
case 'jpeg': | ||
case 'jpg': | ||
case 'png': | ||
case 'webm': | ||
case 'webp': | ||
case 'html': | ||
case 'htm': | ||
case 'zip': | ||
case 'csv': | ||
case 'pdf': | ||
case 'mp4': | ||
return `.${data[1]}`; | ||
} | ||
return 'file'; | ||
} | ||
// set type safe variables | ||
@@ -207,2 +252,11 @@ export function localStorageSet(name, newItem) { | ||
// delete item from local storage | ||
export function localStorageDelete(name) { | ||
try { | ||
return localStorage.removeItem(name); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
// https://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-a-url | ||
@@ -209,0 +263,0 @@ function validURL(str) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80445
2486