Skip to content

Commit

Permalink
db-tabulator: fix wikilinks where page_title starts with a namespace …
Browse files Browse the repository at this point in the history
…name

!restart
  • Loading branch information
siddharthvp committed Nov 27, 2023
1 parent 8c44148 commit ebd9f7c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions db-tabulator/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,16 +415,15 @@ export class Query {
nsColNumber = parseInt(namespace.slice(1)) - 1;
}
result = this.transformColumn(result, columnIndex, (value, rowIdx) => {
try {
let title = new bot.title(value, nsId ?? Number(Object.values(result[rowIdx])[nsColNumber]));
// title.getNamespaceId() need not be same as namespace passed to new bot.title
let colon = [NS_CATEGORY, NS_FILE].includes(title.getNamespaceId()) ? ':' : '';
let pageName = title.toText();
return (showNamespace || title.getNamespaceId() === NS_MAIN) ?
`[[${colon}${pageName}]]` : `[[${colon}${pageName}|${value.replace(/_/g, ' ')}]]`;
} catch (e) {
let title = bot.title.makeTitle(nsId ?? Number(Object.values(result[rowIdx])[nsColNumber]), value);
if (!title) {
return value.replace(/_/g, ' ');
}
// title.getNamespaceId() need not be same as namespace passed to bot.title.makeTitle
let colon = [NS_CATEGORY, NS_FILE].includes(title.getNamespaceId()) ? ':' : '';
let pageName = title.toText();
return (showNamespace || title.getNamespaceId() === NS_MAIN) ?
`[[${colon}${pageName}]]` : `[[${colon}${pageName}|${value.replace(/_/g, ' ')}]]`;
});
});

Expand Down

0 comments on commit ebd9f7c

Please sign in to comment.