Merge pull request #24450 from petejohanson/urijs-template-parse-parts

urijs: Add URITemplate `parse` and `parts` definitions.
This commit is contained in:
Mine Starks
2018-03-22 12:27:11 -07:00
committed by GitHub
2 changed files with 25 additions and 0 deletions
+22
View File
@@ -239,8 +239,30 @@ declare namespace uri {
type URITemplateCallback = (keyName: string) => URITemplateValue;
type URITemplateInput = { [key: string]: URITemplateValue | URITemplateCallback } | URITemplateCallback;
type URITemplateLiteral = string;
interface URITemplateVariable {
name: string;
explode: boolean;
maxLength?: number;
}
interface URITemplateExpression {
expression: string;
operator: string;
variables: ReadonlyArray<URITemplateVariable>;
}
type URITemplatePart = URITemplateLiteral | URITemplateExpression;
interface URITemplate {
expand(data: URITemplateInput, opts?: Object) : URI;
parse(): this;
/**
* @description The parsed parts of the URI Template. Only present after calling
* `parse()` first.
*/
parts?: ReadonlyArray<URITemplatePart>;
}
interface URITemplateStatic {
+3
View File
@@ -109,6 +109,9 @@ URI('http://user:pass@example.org:80/foo/bar.html').equals(
})
);
const template = URITemplate('/items/{?page,count}');
template.parse() === template;
/*
Tests for hasSearch(), hasQuery()
From: http://medialize.github.io/URI.js/docs.html#search-has