mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
Fix document URL generation for titles with only special characters (#9258)
* Fix document URL generation for titles with only special characters * Refactor: Update instance path method to use static getPath method --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
This commit is contained in:
@@ -383,11 +383,10 @@ class Document extends ArchivableModel<
|
||||
|
||||
/** The frontend path to this document. */
|
||||
get path() {
|
||||
if (!this.title) {
|
||||
return `/doc/untitled-${this.urlId}`;
|
||||
}
|
||||
const slugifiedTitle = slugify(this.title);
|
||||
return `/doc/${slugifiedTitle}-${this.urlId}`;
|
||||
return Document.getPath({
|
||||
title: this.title,
|
||||
urlId: this.urlId,
|
||||
});
|
||||
}
|
||||
|
||||
get tasks() {
|
||||
@@ -400,7 +399,13 @@ class Document extends ArchivableModel<
|
||||
if (!title.length) {
|
||||
return `/doc/untitled-${urlId}`;
|
||||
}
|
||||
return `/doc/${slugify(title)}-${urlId}`;
|
||||
const slugifiedTitle = slugify(title);
|
||||
// If the slugified title is empty (e.g., title only had special characters),
|
||||
// use "untitled" as a fallback to prevent empty URL segments
|
||||
if (!slugifiedTitle) {
|
||||
return `/doc/untitled-${urlId}`;
|
||||
}
|
||||
return `/doc/${slugifiedTitle}-${urlId}`;
|
||||
}
|
||||
|
||||
// hooks
|
||||
@@ -867,6 +872,7 @@ class Document extends ArchivableModel<
|
||||
/**
|
||||
* Find all of the child documents for this document
|
||||
*
|
||||
* @param where Omit<WhereOptions<Document>, "parentDocumentId">
|
||||
* @param options FindOptions
|
||||
* @returns A promise that resolve to a list of documents
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user