|
1122 | 1122 | var link = links[i];
|
1123 | 1123 |
|
1124 | 1124 | // Remove canonical links.
|
1125 |
| - if (typeof canonical === 'string' && link.href && typeof link.href === 'string' && link.rel && link.rel.indexOf(CONFIG.R.file) === -1 && link.rel.indexOf(CONFIG.R.iframely) === -1) { |
| 1125 | + if (typeof canonical === 'string' && link.href && typeof link.href === 'string' |
| 1126 | + && link.rel && link.rel.indexOf(CONFIG.R.file) === -1 |
| 1127 | + && link.rel.indexOf(CONFIG.R.iframely) === -1 && link.rel.indexOf(CONFIG.R.oembed) == -1 |
| 1128 | + && !/\/embed\//i.test(canonical)) { |
1126 | 1129 |
|
1127 |
| - // Remove last / from url. |
| 1130 | + // Remove trailing `/`` from url. |
1128 | 1131 |
|
1129 | 1132 | var link1 = link.href.replace(/\/+$/, '');
|
1130 | 1133 | var link2 = canonical.replace(/\/+$/, '');
|
| 1134 | + var link3 = link._uri?.replace(/\/+$/, ''); |
1131 | 1135 |
|
1132 |
| - if (link1 === link2 && link.rel.indexOf(CONFIG.R.oembed) == -1 && !/\/embed\//i.test(canonical)) { |
1133 |
| - // allow the canonical links for oEmbeds, as such mistakes are usually made for OG and Twitter: |
1134 |
| - // if publisher has oEmbed, he is most likely to have the valid embed codes |
1135 |
| - link.error = "Removed canonical link"; |
| 1136 | + if (link1 === link2) { |
| 1137 | + link.error = "Canonical link is removed unlesss explicitely allowed"; |
| 1138 | + } else if (link3 === link2) { |
| 1139 | + link.error = "Link redirected to the canonical"; |
1136 | 1140 | }
|
1137 | 1141 | }
|
1138 | 1142 |
|
|
1182 | 1186 | link.sourceId = i;
|
1183 | 1187 | }
|
1184 | 1188 |
|
1185 |
| - if ('_imageMeta' in link || '_imageStatus' in link) { |
| 1189 | + if ('_imageMeta' in link || '_imageStatus' in link || '_uri' in link) { |
1186 | 1190 |
|
1187 | 1191 | var newLink;
|
1188 | 1192 | if (options.debug) {
|
|
1193 | 1197 |
|
1194 | 1198 | delete newLink._imageMeta;
|
1195 | 1199 | delete newLink._imageStatus;
|
| 1200 | + delete newLink._uri; |
1196 | 1201 | links[i] = newLink;
|
1197 | 1202 | }
|
1198 | 1203 |
|
|
0 commit comments