Jumoo/uSyncMigrations

Error in GUID parsing for related links & related links 2 datatype

drummerboy46 opened this issue · 4 comments

@KevinJump I have a ton of related links content that have guids in various places within the captions and links themselves, see screenshot.

image

The parser isn't quite clever enough to capture the correct portion of the Json and ensure only "link" and "internal" Guids are encapsulated in quotes to create valid Json.

Suggested improvement (as yet untested)

private string WrapGuidsWithQuotes(string value)
{
string guidRegEx = @"(""internal""|""link""):(\b[A-Fa-f0-9]{8}(?:-[A-Fa-f0-9]{4}){3}-[A-Fa-f0-9]{12}\b)";
HashSet uniqueMatches = new HashSet();

    foreach (Match m in Regex.Matches(value, guidRegEx)) {
        uniqueMatches.Add(m.Groups[1].Value);
    }

    foreach (var guid in uniqueMatches) { 
      value = value.Replace(guid, "\"" + guid + "\"")
            .Replace("\"\"", "\"");
    }
    return value;
}

Yeah - i suspect it needs a little looking at and cleaning up & It looks very similar to a bit of code we have somewhere else in the migrations package.

@KevinJump I've cloned the project and fixed this, do I fork to submit a pull request?

yep - If you can, a fork will then let you create a PR. and we will merge it in.

Fixed in phase 4