Skip to content

Commit

Permalink
add external link checking for redirect_to
Browse files Browse the repository at this point in the history
  • Loading branch information
kartva committed Feb 9, 2023
1 parent 5f81df6 commit 79a3ee7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions components/content/src/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use config::Config;
use errors::{Context, Result};
use markdown::{render_content, RenderContext};
use utils::fs::read_file;
use utils::net::is_external_link;
use utils::table_of_contents::Heading;
use utils::templates::{render_template, ShortcodeDefinition};

Expand Down Expand Up @@ -168,7 +169,14 @@ impl Section {
.with_context(|| format!("Failed to render content of {}", self.file.path.display()))?;
self.content = res.body;
self.toc = res.toc;

self.external_links = res.external_links;
if let Some(ref redirect_to) = self.meta.redirect_to {
if is_external_link(redirect_to) {
self.external_links.push(redirect_to.to_owned());
}
}

self.internal_links = res.internal_links;

Ok(())
Expand Down

0 comments on commit 79a3ee7

Please sign in to comment.