Commit 8f50729c authored by Laurent Wouters's avatar Laurent Wouters
Browse files

[fix] Fixed linting issues with ldbrowser

parent d7f89b38fa5c
......@@ -308,9 +308,9 @@ chrome.runtime.onMessage.addListener(
allObservations,
sender.tab.id
);
if (observation.primaryTopic === "") {
if (observation.primaryTopic.length === 0) {
let topic = detectTopicOnlinks(request.payload);
observation.primaryTopic = topic !== null ? topic : "";
observation.primaryTopic = topic;
}
observation.sources = observation.sources.concat(
detectDataOnLinks(request.payload, {
......
......@@ -65,7 +65,7 @@ export class CurrentTabCompliance extends React.Component<
<div className="card-header">Source from redirection</div>
<div className="card-body">
The source of data at <a href={w.source.url}>{w.source.url}</a> has
been found through a rediction.
been found through a redirection.
</div>
</div>
);
......
......@@ -154,13 +154,11 @@ export function parseLinks(content: string): Link[] {
* Detects the primary topic in the links
* @param links The links in the header
*/
export function detectTopicOnlinks(links: Link[]): string | null {
return links
.filter((link: Link) => refersToPrimaryTopic(link))
.reduce(
(acc: string | null, link: Link) => (acc !== null ? acc : link.url),
null
);
export function detectTopicOnlinks(links: Link[]): string {
for (let i = 0; i !== links.length; i++) {
if (refersToPrimaryTopic(links[i])) return links[i].url;
}
return "";
}
/**
......@@ -186,11 +184,11 @@ export function detectDataOnLinks(
export function findLinksInDocument(
document: HTMLDocument,
url: string,
primaryTopic: string | null
primaryTopic: string
): Link[] {
let links: Link[] = [];
let resource = primaryTopic;
if (resource === null) {
if (resource.length === 0) {
resource = url;
}
......@@ -707,7 +705,7 @@ export function observeContent(
);
let observations: DocumentObservations = {
origin: origin,
primaryTopic: primary === null ? "" : primary,
primaryTopic: primary,
url: observable.url,
sources: [source],
preemptable: true,
......@@ -732,7 +730,7 @@ export function observeContent(
);
let otherLinks = findLinksInDocument(doc, observable.url, primary);
links = links.concat(otherLinks);
if (primary === null || primary === "") {
if (primary.length === 0) {
primary = detectTopicOnlinks(links);
}
}
......@@ -745,7 +743,7 @@ export function observeContent(
);
let observations: DocumentObservations = {
origin: origin,
primaryTopic: primary === null ? "" : primary,
primaryTopic: primary,
url: observable.url,
sources: sources,
preemptable: MIME.hasOwnProperty(observable.contentType),
......
......@@ -183,7 +183,7 @@ export class MetaPropertyData implements MetaProperty {
return { literal: literal, rank: l } as RankedLiteral;
}
}
if (literal.lang === "") {
if (literal.lang.length === 0) {
// lang-tag is not defined, has more priority than other tagged literals that do not match (considered as a default)
return {
literal: literal,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment