Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class InternalLinkResolverImpl implements Resolver {

private String internalLinksHost;
private boolean enabled;
private boolean checkAsExternal;

@Reference
private Resolver externalLinkResolver;
Expand All @@ -66,6 +67,7 @@ public class InternalLinkResolverImpl implements Resolver {
private void activate(InternalLinkResolverConfig config) {
this.enabled = config.enabled();
this.internalLinksHost = config.internalLinksHost();
this.checkAsExternal = config.checkAsExternal();
}

/**
Expand Down Expand Up @@ -102,7 +104,7 @@ public void validate(Result result, ResourceResolver resourceResolver) {
return;
}
Status status = checkLink(result.getValue(), resourceResolver);
if (status.getCode() == HttpStatus.SC_NOT_FOUND && StringUtils.isNotBlank(internalLinksHost)) {
if ((status.getCode() == HttpStatus.SC_NOT_FOUND || checkAsExternal) && StringUtils.isNotBlank(internalLinksHost)) {
String prefix = StringUtils.startsWithAny(internalLinksHost, HTTP_SCHEMA, HTTPS_SCHEMA) ? EMPTY : HTTPS_SCHEMA;
String origin = StringUtils.stripEnd(internalLinksHost, "/");
SlingUriBuilder slingUri = SlingUriBuilder.parse(result.getValue(), resourceResolver);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
)
boolean enabled() default true;

@AttributeDefinition(
name = "Check Internal Links as External?",
Comment thread
AlKaliada marked this conversation as resolved.
Outdated
description = "Check internal links as external ones by sending HTTP requests to the server. Internal links host should be specified for this to work properly"
)
boolean checkAsExternal() default false;

@AttributeDefinition(
name = "Internal Links Host",
description = "Host to be used for verifying internal links. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import java.net.URI;
import java.util.Map;
import java.util.function.Consumer;
import org.apache.sling.api.request.RequestPathInfo;
import org.apache.sling.api.resource.Resource;
import org.osgi.annotation.versioning.ProviderType;

@ProviderType
public interface SlingUri extends RequestPathInfo {
public interface SlingUri {
Comment thread
AlKaliada marked this conversation as resolved.
Outdated
URI toUri();

String toString();
Expand Down
8 changes: 4 additions & 4 deletions ui.content/src/main/content/META-INF/vault/filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
<!-- System user -->
<filter root="/home/users/system/etoolbox/YhFMjFNu-eqtti9pXW7O"/>
<filter root="/conf/etoolbox/link-inspector/rep:policy"/>
<filter root="/content/rep:policy"/>
<filter root="/content/etoolbox/rep:policy"/>
<filter root="/content/rep:policy" mode="merge"/>
<filter root="/content/etoolbox/rep:policy" mode="merge"/>
<!-- Main content -->
<filter root="/content/etoolbox/link-inspector"/>
<filter root="/content/etoolbox/link-inspector" mode="merge"/>
<!-- Subsidiary content -->
<filter root="/var/etoolbox/link-inspector/data/rep:policy"/>
<filter root="/var/etoolbox/link-inspector/download/rep:policy"/>
<!-- Removal of obsolete paths -->
<filter root="/conf/etoolbox-link-inspector"/>
<filter root="/content/etoolbox-link-inspector"/>
<filter root="/content/etoolbox-link-inspector" mode="merge"/>
</workspaceFilter>