Permalink
Browse files

preload: strip existing rel=preload hints

Fixes #1327
  • Loading branch information...
jeffkaufman authored and crowell committed Jun 27, 2016
1 parent 19cf3bb commit dbde98953a796e16fee3fa9afe8c3af444d9e242
@@ -51,7 +51,9 @@ void StripSubresourceHintsFilter::StartElement(HtmlElement* element) {

if (element->keyword() == HtmlName::kLink) {
const char *value = element->AttributeValue(HtmlName::kRel);
if (value && StringCaseEqual(value, "subresource")) {
if (value && (
StringCaseEqual(value, "subresource") ||
StringCaseEqual(value, "preload"))) {
const RewriteOptions *options = driver_->options();
const char *resource_url = element->AttributeValue(HtmlName::kSrc);
if (!resource_url) {
@@ -156,6 +156,16 @@ TEST_F(StripSubresourceHintsFilterTest, SingleResourceValidLink) {
ValidateStripSubresourceHint(source, rewritten);
}

TEST_F(StripSubresourceHintsFilterTest, SingleResourceValidPreloadLink) {
const char *source =
"<head><link rel=\"preload\" src=\"/test.gif\" as=\"image\"/></head>"
"<body><img src=\"1.jpg\"/></body>";
const char *rewritten =
"<head></head>"
"<body><img src=\"1.jpg\"/></body>";
ValidateStripSubresourceHint(source, rewritten);
}

TEST_F(StripSubresourceHintsFilterTest, SingleResourceExternalLink) {
const char *source =
"<head>"

0 comments on commit dbde989

Please sign in to comment.