Skip to content

Commit 19ea3e0

Browse files
committed
Merge branch 'develop' of https://github.com/wordpress-mobile/WordPress-Android into feature/Plans-M1-Show-Plans-List
Conflicts: WordPress/src/main/java/org/wordpress/android/WordPressDB.java
2 parents 06fb0e9 + 62db2a7 commit 19ea3e0

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

WordPressUtils/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ android {
3232
buildToolsVersion "23.0.2"
3333

3434
defaultConfig {
35-
versionName "1.8.0"
35+
versionName "1.9.0"
3636
minSdkVersion 14
3737
targetSdkVersion 23
3838
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.wordpress.android.util;
2+
3+
import android.test.InstrumentationTestCase;
4+
5+
public class ShortcodeUtilsTest extends InstrumentationTestCase {
6+
public void testGetVideoPressShortcodeFromId() {
7+
assertEquals("[wpvideo abcd1234]", ShortcodeUtils.getVideoPressShortcodeFromId("abcd1234"));
8+
}
9+
10+
public void testGetVideoPressShortcodeFromNullId() {
11+
assertEquals("", ShortcodeUtils.getVideoPressShortcodeFromId(null));
12+
}
13+
14+
public void testGetVideoPressIdFromCorrectShortcode() {
15+
assertEquals("abcd1234", ShortcodeUtils.getVideoPressIdFromShortCode("[wpvideo abcd1234]"));
16+
}
17+
18+
public void testGetVideoPressIdFromInvalidShortcode() {
19+
assertEquals("", ShortcodeUtils.getVideoPressIdFromShortCode("[other abcd1234]"));
20+
}
21+
22+
public void testGetVideoPressIdFromNullShortcode() {
23+
assertEquals("", ShortcodeUtils.getVideoPressIdFromShortCode(null));
24+
}
25+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package org.wordpress.android.util;
2+
3+
import java.util.regex.Matcher;
4+
import java.util.regex.Pattern;
5+
6+
public class ShortcodeUtils {
7+
public static String getVideoPressShortcodeFromId(String videoPressId) {
8+
if (videoPressId == null || videoPressId.isEmpty()) {
9+
return "";
10+
}
11+
12+
return "[wpvideo " + videoPressId + "]";
13+
}
14+
15+
public static String getVideoPressIdFromShortCode(String shortcode) {
16+
String videoPressId = "";
17+
18+
if (shortcode != null) {
19+
String videoPressShortcodeRegex = "^\\[wpvideo (.*)]$";
20+
21+
Pattern pattern = Pattern.compile(videoPressShortcodeRegex);
22+
Matcher matcher = pattern.matcher(shortcode);
23+
24+
if (matcher.find()) {
25+
videoPressId = matcher.group(1);
26+
}
27+
}
28+
29+
return videoPressId;
30+
}
31+
}

0 commit comments

Comments
 (0)