@@ -1133,6 +1133,30 @@ class PathHierarchyTests: XCTestCase {
11331133 XCTAssertNil ( articleNode. symbol, " General documentation link find the article " )
11341134 }
11351135
1136+ func testArticleSelfAnchorLinks( ) throws {
1137+ try XCTSkipUnless ( LinkResolutionMigrationConfiguration . shouldUseHierarchyBasedLinkResolver)
1138+ let ( _, _, context) = try testBundleAndContext ( copying: " MixedLanguageFramework " ) { url in
1139+ try """
1140+ # ArticleWithHeading
1141+
1142+ ## TestTargetHeading
1143+
1144+ This article has the same path as a symbol. See also:
1145+ - <doc:TestTargetHeading>
1146+ - <doc:#TestTargetHeading>
1147+
1148+ """ . write ( to: url. appendingPathComponent ( " ArticleWithHeading.md " ) , atomically: true , encoding: . utf8)
1149+ }
1150+
1151+ let tree = try XCTUnwrap ( context. hierarchyBasedLinkResolver? . pathHierarchy)
1152+ let articleNode = try tree. findNode ( path: " /MixedLanguageFramework/ArticleWithHeading " , onlyFindSymbols: false )
1153+
1154+ let linkNode = try tree. find ( path: " TestTargetHeading " , parent: articleNode. identifier, onlyFindSymbols: false )
1155+ let anchorLinkNode = try tree. find ( path: " #TestTargetHeading " , parent: articleNode. identifier, onlyFindSymbols: false )
1156+ XCTAssertNotNil ( linkNode)
1157+ XCTAssertNotNil ( anchorLinkNode)
1158+ }
1159+
11361160 func testOverloadedSymbols( ) throws {
11371161 try XCTSkipUnless ( LinkResolutionMigrationConfiguration . shouldUseHierarchyBasedLinkResolver)
11381162 let ( _, context) = try testBundleAndContext ( named: " OverloadedSymbols " )
@@ -1555,6 +1579,7 @@ class PathHierarchyTests: XCTestCase {
15551579 assertParsedPathComponents ( " first/ " , [ ( " first " , nil , nil ) ] )
15561580 assertParsedPathComponents ( " first//second " , [ ( " first " , nil , nil ) , ( " second " , nil , nil ) ] )
15571581 assertParsedPathComponents ( " first/second#third " , [ ( " first " , nil , nil ) , ( " second " , nil , nil ) , ( " third " , nil , nil ) ] )
1582+ assertParsedPathComponents ( " #first " , [ ( " first " , nil , nil ) ] )
15581583
15591584 // Check disambiguation
15601585 assertParsedPathComponents ( " path-hash " , [ ( " path " , nil , " hash " ) ] )
0 commit comments