diff --git a/eipw-lint/tests/lint_markdown_relative_links.rs b/eipw-lint/tests/lint_markdown_relative_links.rs index 64c66fb5..d3406440 100644 --- a/eipw-lint/tests/lint_markdown_relative_links.rs +++ b/eipw-lint/tests/lint_markdown_relative_links.rs @@ -1,7 +1,7 @@ /* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * file. You can obtain one at https://mozilla.org/MPL/2.0/. */ use eipw_lint::lints::markdown::RelativeLinks; @@ -69,6 +69,63 @@ header: value1 ); } +#[tokio::test] +async fn inline_link_with_scheme_to_eips_ethereum_org() { + let src = r#"--- +header: value1 +--- + +[hello](https://eips.ethereum.org/EIPS/eip-1234) +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | [hello](https://eips.ethereum.org/EIPS/eip-1234) + | + = help: use `./eip-1234.md` instead +"# + ); +} + +#[tokio::test] +async fn inline_link_with_scheme_and_numbers() { + let src = r#"--- +header: value1 +--- + +[hi](https://example.com/4444) +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | [hi](https://example.com/4444) + | +"# + ); +} + #[tokio::test] async fn inline_link_protocol_relative() { let src = r#"--- @@ -224,6 +281,37 @@ Hello [hi][hello]! assert_eq!(reports, ""); } +#[tokio::test] +async fn reference_link_with_scheme_to_eips_ethereum_org() { + let src = r#"--- +header: value1 +--- + +Hello [hi][hello]! + +[hello]: https://eips.ethereum.org/EIPS/eip-1234 +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | Hello [hi][hello]! + | + = help: use `./eip-1234.md` instead +"# + ); +} + #[tokio::test] async fn inline_autolink() { let src = r#"--- @@ -325,6 +413,35 @@ header: value1 ); } +#[tokio::test] +async fn anchor_link_protocol_relative_to_eips_ethereum_org() { + let src = r#"--- +header: value1 +--- + +example +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | example + | + = help: use `./eip-1234.md` instead +"# + ); +} + #[tokio::test] async fn anchor_link_relative_double_slash() { let src = r#"--- @@ -409,3 +526,32 @@ header: value1 "# ); } + +#[tokio::test] +async fn img_protocol_relative_to_eips_ethereum_org() { + let src = r#"--- +header: value1 +--- + + +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | + | + = help: use `../assets/eip-712/eth_sign.png` instead +"# + ); +}