Skip to content

Commit 946aabc

Browse files
authored
Merge pull request #7593 from schrodingersket/bugfix/7503
#7503: Added check for nullish `created`/`last_edited` timestamps on public share records.
2 parents 078640e + 41c8fa6 commit 946aabc

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/packages/next/components/path/path.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export interface PublicPathProps {
7171
// doesn't use the names. See https://github.com/sagemathinc/cocalc/issues/6115
7272
redirect?: string;
7373
jupyter_api: boolean;
74-
created?: string; // ISO 8601 string
75-
last_edited?: string; // ISO 8601 string
74+
created: string|null; // ISO 8601 string
75+
last_edited: string|null; // ISO 8601 string
7676
ogUrl?: string; // Open Graph URL for social media sharing
7777
}
7878

src/packages/next/lib/share/get-public-path-info.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,18 @@ export default async function getPublicPathInfo({
113113
basePath,
114114
isStarred,
115115
...details,
116-
created: rows[0].created.toISOString(),
117-
last_edited: rows[0].last_edited.toISOString(),
116+
created: rows[0].created?.toISOString() ?? null,
117+
last_edited: rows[0].last_edited?.toISOString() ?? null,
118118
};
119119
} catch (error) {
120-
return { id, ...rows[0], relativePath, isStarred, error: error.toString() };
120+
return {
121+
id,
122+
...rows[0],
123+
relativePath,
124+
isStarred,
125+
created: rows[0].created?.toISOString() ?? null,
126+
last_edited: rows[0].last_edited?.toISOString() ?? null,
127+
error: error.toString(),
128+
};
121129
}
122130
}

src/packages/next/pages/share/public_paths/[...id].tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@ export default (props: PublicPathProps) => (
3434
/>
3535
)}
3636

37-
<meta property="article:published_time" content={props.created} />
38-
<meta property="article:modified_time" content={props.last_edited} />
37+
{props.created && (
38+
<meta property="article:published_time" content={props.created}/>
39+
)}
40+
{props.last_edited && (
41+
<meta property="article:modified_time" content={props.last_edited}/>
42+
)}
3943
</NextHead>
4044
</>
4145
);

0 commit comments

Comments
 (0)