@Test public void testTranslateAnchor() { assertEquals("", target.translateTag("")); assertEquals("<a></a>", target.translateTag("<a></a>")); assertEquals("<a/>", target.translateTag("<a/>")); assertEquals("<a href></a>", target.translateTag("<a href></a>")); assertEquals("<a href=\"\"></a>", target.translateTag("<a href=\"\"></a>")); assertEquals("<a href=\"\"></a>", target.translateTag("<a href=''></a>")); assertEquals("<a href= \"\" ></a>", target.translateTag("<a href= '' ></a>")); }
@VisibleForTesting String translateTag(String tag) { Tuple3<Integer, Integer, String> value = attributeValue(tag); if (value.isNull()) return tag; String newUrl = urlMapper.mapContentUrl(value.e3); return left(tag, value.e1) + dquoteAround(newUrl) + substring(tag, value.e2); }
TagTranslator { @VisibleForTesting String translateTag(String tag) { Tuple3<Integer, Integer, String> value = attributeValue(tag); if (value.isNull()) return tag; String newUrl = urlMapper.mapContentUrl(value.e3); return left(tag, value.e1) + dquoteAround(newUrl) + substring(tag, value.e2); } }
TagTranslator { @VisibleForTesting String translateTag(String tag) { Tuple3<Integer, Integer, String> value = attributeValue(tag); if (value.isNull()) return tag; String newUrl = urlMapper.mapContentUrl(value.e3); return left(tag, value.e1) + dquoteAround(newUrl) + substring(tag, value.e2); } TagTranslator(Mapping mapping, Pattern tagPattern, Pattern attributePattern); }
TagTranslator { @VisibleForTesting String translateTag(String tag) { Tuple3<Integer, Integer, String> value = attributeValue(tag); if (value.isNull()) return tag; String newUrl = urlMapper.mapContentUrl(value.e3); return left(tag, value.e1) + dquoteAround(newUrl) + substring(tag, value.e2); } TagTranslator(Mapping mapping, Pattern tagPattern, Pattern attributePattern); String translate(String text); }
TagTranslator { @VisibleForTesting String translateTag(String tag) { Tuple3<Integer, Integer, String> value = attributeValue(tag); if (value.isNull()) return tag; String newUrl = urlMapper.mapContentUrl(value.e3); return left(tag, value.e1) + dquoteAround(newUrl) + substring(tag, value.e2); } TagTranslator(Mapping mapping, Pattern tagPattern, Pattern attributePattern); String translate(String text);  }