Skip to content

Commit

Permalink
fix(bcd): re-surface "see bug xxxxx" notes (#10549)
Browse files Browse the repository at this point in the history
bcd migrated to using the `impl_url` field over the `notes` field in
most cases: mdn/browser-compat-data#20608

this commit attempts to bring back the same functionality as before
  • Loading branch information
LeoMcA authored Feb 19, 2024
1 parent 2f4a09d commit 6da4660
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
isTruthy,
versionIsPreview,
SupportStatementExtended,
bugURLToString,
} from "./utils";
import { LEGEND_LABELS } from "./legend";
import { DEFAULT_LOCALE } from "../../../../../libs/constants";
Expand Down Expand Up @@ -373,6 +374,19 @@ function getNotes(
(note) => ({ iconName: "footnote", label: note })
)
: null,
item.impl_url
? (Array.isArray(item.impl_url)
? item.impl_url
: [item.impl_url]
).map((impl_url) => ({
iconName: "footnote",
label: (
<>
See <a href={impl_url}>{bugURLToString(impl_url)}</a>.
</>
),
}))
: null,
versionIsPreview(item.version_added, browser)
? {
iconName: "footnote",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,21 @@ export function versionIsPreview(

export function hasNoteworthyNotes(support: BCD.SimpleSupportStatement) {
return (
support.notes?.length &&
(support.notes?.length || support.impl_url?.length) &&
!support.version_removed &&
!support.partial_implementation
);
}

export function bugURLToString(url: string) {
const bugNumber = url.match(
/^https:\/\/(?:crbug\.com|webkit\.org\/b|bugzil\.la)\/([0-9]+)/i
)?.[1];
return bugNumber ? `bug ${bugNumber}` : url;
}

function hasLimitation(support: BCD.SimpleSupportStatement) {
return hasMajorLimitation(support) || support.notes;
return hasMajorLimitation(support) || support.notes || support.impl_url;
}

function hasMajorLimitation(support: BCD.SimpleSupportStatement) {
Expand Down

0 comments on commit 6da4660

Please sign in to comment.