mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
DASH UrlTemplate parses template if it contains more than one time each identifier
This commit is contained in:
parent
144bd72236
commit
eb5cbd902b
1 changed files with 10 additions and 5 deletions
|
|
@ -51,11 +51,16 @@ public final class UrlTemplate {
|
||||||
* @throws IllegalArgumentException If the template string is malformed.
|
* @throws IllegalArgumentException If the template string is malformed.
|
||||||
*/
|
*/
|
||||||
public static UrlTemplate compile(String template) {
|
public static UrlTemplate compile(String template) {
|
||||||
// These arrays are sizes assuming each of the four possible identifiers will be present at
|
// We can have more than once each identifier in the template so we need
|
||||||
// most once in the template, which seems like a reasonable assumption.
|
// to count the total number of identifiers present in the template
|
||||||
String[] urlPieces = new String[5];
|
int identifiersCount = 0;
|
||||||
int[] identifiers = new int[4];
|
String[] identifiersNames = { REPRESENTATION, NUMBER, BANDWIDTH, TIME };
|
||||||
String[] identifierFormatTags = new String[4];
|
for(String identifierName : identifiersNames){
|
||||||
|
identifiersCount += template.split("\\$" + identifierName + "\\$").length - 1;
|
||||||
|
}
|
||||||
|
String[] urlPieces = new String[identifiersCount+1];
|
||||||
|
int[] identifiers = new int[identifiersCount];
|
||||||
|
String[] identifierFormatTags = new String[identifiersCount];
|
||||||
int identifierCount = parseTemplate(template, urlPieces, identifiers, identifierFormatTags);
|
int identifierCount = parseTemplate(template, urlPieces, identifiers, identifierFormatTags);
|
||||||
return new UrlTemplate(urlPieces, identifiers, identifierFormatTags, identifierCount);
|
return new UrlTemplate(urlPieces, identifiers, identifierFormatTags, identifierCount);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue