@@ -116,11 +116,16 @@ func checkIfPageIdsOverlap(oldPageId string, newPageId string) bool {
116
116
// `create-mongodb-user-for-cluster` - is what we're considering the page title
117
117
oldPageName := getPageTitleFromId (oldPageId )
118
118
newPageName := getPageTitleFromId (newPageId )
119
+ newPageSegments := getExtendedPageTitleFromId (newPageName )
119
120
120
121
// The simplest case is a restructure that moves the pages from one directory to another without any changes.
121
122
// If the page name is an exact match, we can return true, because the page title overlaps 100%
122
123
if oldPageName == newPageName {
123
124
return true
125
+ // In some cases, the page may have become a title page for a section, and may now have pages below it. Check
126
+ // if the old page name is up a directory level.
127
+ } else if contains (newPageSegments , oldPageName ) {
128
+ return true
124
129
} else {
125
130
// If it's not a 1:1 move the page without changing the title situation, we can compare the page titles to try
126
131
// to figure out if it has enough overlap to be effectively the same page title
@@ -140,6 +145,24 @@ func getPageTitleFromId(pageId string) string {
140
145
}
141
146
}
142
147
148
+ func getExtendedPageTitleFromId (pageId string ) []string {
149
+ parts := strings .Split (pageId , "|" )
150
+
151
+ var titleSegments []string
152
+ // Get the last element
153
+ if len (parts ) > 0 {
154
+ lastElement := parts [len (parts )- 1 ] // Access the last index
155
+ titleSegments = append (titleSegments , lastElement )
156
+ }
157
+ // If there are multiple elements, get the second-to-last element. This may contain something that _used_ to match
158
+ // the page ID when we are now nesting pages below it
159
+ if len (parts ) > 1 {
160
+ secondToLastElement := parts [len (parts )- 2 ]
161
+ titleSegments = append (titleSegments , secondToLastElement )
162
+ }
163
+ return titleSegments
164
+ }
165
+
143
166
func pageNamesHaveCommonElements (oldPageName string , newPageName string ) bool {
144
167
// Split the page names by `-` to get the words in the name for common comparison
145
168
oldPageNameParts := strings .Split (oldPageName , "-" )
0 commit comments