Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,19 @@ public string ProcessStringValue(string input)

private (Guid Key, string EntityType)? CreateIntBasedKeyType(int id)
{
// very old data, best effort replacement
// very old data, best effort replacement.
// entity type must match the lowercase UDI entity type, which is what the tiptap RTE
// expects in the "type" attribute (and what the UDI-based branch above produces).
Attempt<Guid> documentAttempt = _idKeyMap.GetKeyForId(id, UmbracoObjectTypes.Document);
if (documentAttempt.Success)
{
return (Key: documentAttempt.Result, EntityType: UmbracoObjectTypes.Document.ToString());
return (Key: documentAttempt.Result, EntityType: Constants.UdiEntityType.Document);
}

Attempt<Guid> mediaAttempt = _idKeyMap.GetKeyForId(id, UmbracoObjectTypes.Media);
if (mediaAttempt.Success)
{
return (Key: mediaAttempt.Result, EntityType: UmbracoObjectTypes.Media.ToString());
return (Key: mediaAttempt.Result, EntityType: Constants.UdiEntityType.Media);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ public string ProcessStringValue(string input)

private (Guid Key, string EntityType)? CreateIntBasedKeyType(int id)
{
// very old data, best effort replacement
// very old data, best effort replacement.
// entity type must match the lowercase UDI entity type, which is what the tiptap RTE
// expects in the "type" attribute.
Attempt<Guid> documentAttempt = _idKeyMap.GetKeyForId(id, UmbracoObjectTypes.Document);
if (documentAttempt.Success)
{
return (Key: documentAttempt.Result, EntityType: UmbracoObjectTypes.Document.ToString());
return (Key: documentAttempt.Result, EntityType: Constants.UdiEntityType.Document);
}

Attempt<Guid> mediaAttempt = _idKeyMap.GetKeyForId(id, UmbracoObjectTypes.Media);
if (mediaAttempt.Success)
{
return (Key: mediaAttempt.Result, EntityType: UmbracoObjectTypes.Media.ToString());
return (Key: mediaAttempt.Result, EntityType: Constants.UdiEntityType.Media);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ public void ProcessStringValue_IntegerDocumentLink_ConvertsToGuidWithType()
var result = processor.ProcessStringValue(input);

Assert.AreEqual(
$@"<a href=""{{localLink:{documentKey}}}"" type=""Document"">link</a>",
$@"<a href=""{{localLink:{documentKey}}}"" type=""document"">link</a>",
result);
}

/// <summary>
/// Verifies that an integer-based link that resolves to media (not document)
/// is converted with the correct "Media" type attribute.
/// is converted with the correct "media" type attribute.
/// </summary>
[Test]
public void ProcessStringValue_IntegerMediaLink_ConvertsToGuidWithType()
Expand All @@ -115,7 +115,7 @@ public void ProcessStringValue_IntegerMediaLink_ConvertsToGuidWithType()
var result = processor.ProcessStringValue(input);

Assert.AreEqual(
$@"<a href=""{{localLink:{mediaKey}}}"" type=""Media"">link</a>",
$@"<a href=""{{localLink:{mediaKey}}}"" type=""media"">link</a>",
result);
}

Expand Down Expand Up @@ -305,7 +305,7 @@ public void ProcessStringValue_IntegerLink_WithFragment_PreservesFragment()
var result = processor.ProcessStringValue(input);

Assert.AreEqual(
$@"<a href=""{{localLink:{documentKey}}}#anchor"" type=""Document"">link</a>",
$@"<a href=""{{localLink:{documentKey}}}#anchor"" type=""document"">link</a>",
result);
}

Expand All @@ -328,7 +328,7 @@ public void ProcessStringValue_IntegerLink_WithQueryString_PreservesQueryString(
var result = processor.ProcessStringValue(input);

Assert.AreEqual(
$@"<a href=""{{localLink:{documentKey}}}?page=2"" type=""Document"">link</a>",
$@"<a href=""{{localLink:{documentKey}}}?page=2"" type=""document"">link</a>",
result);
}

Expand Down
Loading