Bug 990672 - Remove query string from linked CSS file path in style editor; r=pbrosset

This commit is contained in:
Heather Arthur 2014-04-01 16:44:00 +02:00
parent 1ed8b5fa5c
commit 2531375fbc
2 changed files with 18 additions and 4 deletions

View File

@ -172,14 +172,16 @@ StyleSheetEditor.prototype = {
let relatedSheet = this.styleSheet.relatedStyleSheet;
let path;
var uri = NetUtil.newURI(relatedSheet.href);
let href = removeQuery(relatedSheet.href);
let uri = NetUtil.newURI(href);
if (uri.scheme == "file") {
var file = uri.QueryInterface(Ci.nsIFileURL).file;
let file = uri.QueryInterface(Ci.nsIFileURL).file;
path = file.path;
}
else if (this.savedFile) {
let origUri = NetUtil.newURI(this.styleSheet.href);
let origHref = removeQuery(this.styleSheet.href);
let origUri = NetUtil.newURI(origHref);
path = findLinkedFilePath(uri, origUri, this.savedFile);
}
else {
@ -700,3 +702,15 @@ function findUnsharedBranches(origUri, uri) {
origBranch: origUri
};
}
/**
* Remove the query string from a url.
*
* @param {string} href
* Url to remove query string from
* @return {string}
* Url without query string
*/
function removeQuery(href) {
return href.replace(/\?.*/, "");
}

View File

@ -3,7 +3,7 @@
<head>
<title>testcase for testing CSS source maps</title>
<link rel="stylesheet" type="text/css" href="simple.css"/>
<link rel="stylesheet" type="text/css" href="sourcemap-css/sourcemaps.css"/>
<link rel="stylesheet" type="text/css" href="sourcemap-css/sourcemaps.css?test=1"/>
</head>
<body>
<div>source maps <span>testcase</span></div>