Permalink
Browse files

Support actual-source-URL relative downloadURL and updateURL meta.

Fixes #1658
  • Loading branch information...
1 parent 578d4e5 commit 059a71c329397c16270a7e459e914df97af8cca0 @arantius arantius committed Oct 17, 2012
Showing with 12 additions and 3 deletions.
  1. +12 −3 modules/parseScript.js
View
@@ -7,6 +7,8 @@ Components.utils.import('resource://greasemonkey/scriptResource.js');
Components.utils.import('resource://greasemonkey/third-party/MatchPattern.js');
Components.utils.import('resource://greasemonkey/util.js');
+var gIoService = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService);
var gLineSplitRegexp = /.+/g;
var gAllMetaRegexp = new RegExp(
'^// ==UserScript==([\\s\\S]*?)^// ==/UserScript==', 'm');
@@ -54,15 +56,22 @@ function parse(aSource, aUri, aFailWhenMissing, aNoMetaOk) {
case 'description':
case 'name':
case 'namespace':
- case 'updateURL':
case 'version':
script['_' + header] = value;
break;
- case 'downloadURL':
case 'installURL':
- script._downloadURL = value;
+ header = 'downloadURL';
+ case 'downloadURL':
+ case 'updateURL':
+ try {
+ var uri = GM_util.uriFromUrl(value, aUri || this._downloadURL);
+ script['_' + header] = uri.spec;
+ } catch (e) {
+ dump('Failed to parse ' + header + ' "' + value + '":\n' + e + '\n');
+ }
break;
+
case 'exclude':
script._excludes.push(value);
break;

0 comments on commit 059a71c

Please sign in to comment.