Fix error when adding link attachment with unparseable URL
https://forums.zotero.org/discussion/105158/zotero-7-beta-attach-link-to-uri-logosres-does-not-work-any-longer
This commit is contained in:
parent
a4c3f5267b
commit
42572efca9
1 changed files with 12 additions and 4 deletions
|
@ -2885,10 +2885,18 @@ Zotero.Attachments = new function(){
|
|||
}
|
||||
|
||||
|
||||
this._getExtensionFromURL = function(url, contentType) {
|
||||
var nsIURL = Services.io.newURI(url)
|
||||
.QueryInterface(Ci.nsIURL);
|
||||
return Zotero.MIME.getPrimaryExtension(contentType, nsIURL.fileExtension);
|
||||
this._getExtensionFromURL = function (url, contentType) {
|
||||
let fileExtension;
|
||||
try {
|
||||
let nsIURL = Services.io.newURI(url)
|
||||
.QueryInterface(Ci.nsIURL);
|
||||
fileExtension = nsIURL.fileExtension;
|
||||
}
|
||||
catch (e) {
|
||||
// The URI is not a URL
|
||||
fileExtension = '';
|
||||
}
|
||||
return Zotero.MIME.getPrimaryExtension(contentType, fileExtension);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue