Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
fix(linter-rules/no-http-props): ignore empty URIs (speced#3756)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Aug 24, 2021
1 parent 408df96 commit df17683
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/linter-rules/no-http-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function run(conf) {

const offendingMembers = Object.getOwnPropertyNames(conf)
// this check is cheap, "prevED" is w3c exception.
.filter(key => key.endsWith("URI") || key === "prevED")
.filter(key => (key.endsWith("URI") && conf[key]) || key === "prevED")
// this check is expensive, so separate step
.filter(key =>
new URL(conf[key], parent.location.href).href.startsWith("http://")
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/core/linter-rules/no-http-props-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ describe("Core Linter Rule - 'no-http-props'", () => {
);
}

it("skips over defined, but empty, URIs", async () => {
const conf = {
undefined_URI: undefined,
empty_URI: "",
null_URI: null,
URI: "http://fail",
};
const warnings = await getWarnings(conf);
expect(warnings).toHaveSize(1);
});

it("checks any prop ending with 'URI' (case sensitive)", async () => {
const conf = {
undefined_URI: undefined,
FAIL_uri: "http://fail",
failURIfail: "http://fail",
URI: "http://pass",
Expand Down

0 comments on commit df17683

Please sign in to comment.