Skip to content

Commit

Permalink
Merge pull request #15 from dontcallmedom/newwebreflinks
Browse files Browse the repository at this point in the history
Adapt to new link structure in webref
  • Loading branch information
dontcallmedom authored Mar 28, 2024
2 parents 12fd5f0 + a1ab098 commit fec4bea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
5 changes: 3 additions & 2 deletions lib/list-removed-targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ async function listRemovedTargets(spec, webrefPath) {

const removedTargets = [];
for (const url of pages) {
const linkingSpecs = webrefCrawl.results.filter(s => s.links && s.links[url]?.anchors);
const linkingSpecs = webrefCrawl.results.filter(s => s.links && (s.links.rawlinks[url]?.anchors || s.links.autolinks[url]?.anchors));
for (const s of linkingSpecs) {
const brokenLinks = s.links[url].anchors.filter(a => {
const anchors = (s.links.rawlinks[url]?.anchors ?? []).concat(s.links.autolinks[url]?.anchors ?? []);
const brokenLinks = anchors.filter(a => {
const page = spec.nightly?.pages ? url.replace(baseDirUrl(url), '') : '';
return disappearedAnchors.find(d => d === page + "#" + a);
});
Expand Down
60 changes: 34 additions & 26 deletions test/webref/ed/links/linking-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,41 @@
"url": "http://example.com/specs/linking-spec/"
},
"links": {
"https://example.com/single-page": {
"anchors": [
"valid1",
"valid2"
]
"rawlinks": {
"https://example.com/single-page": {
"anchors": [
"valid2"
]
},
"https://example.com/multi-page/": {
"anchors": [
"valid1"
]
},
"https://example.com/multi-page/subpage.html": {
"anchors": [
"valid1",
"valid2"
]
},
"https://example.com/multi-page/subpage2.html": {
"anchors": [
"valid1",
"valid2"
]
},
"https://example.com/multi-page/subpage3.html": {
"anchors": [
"valid1"
]
}
},
"https://example.com/multi-page/": {
"anchors": [
"valid1"
]
},
"https://example.com/multi-page/subpage.html": {
"anchors": [
"valid1",
"valid2"
]
},
"https://example.com/multi-page/subpage2.html": {
"anchors": [
"valid1",
"valid2"
]
},
"https://example.com/multi-page/subpage3.html": {
"anchors": [
"valid1"
]
"autolinks": {
"https://example.com/single-page": {
"anchors": [
"valid1"
]
}
}
}
}

0 comments on commit fec4bea

Please sign in to comment.