mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-09-22 00:50:25 +00:00
Merge pull request #24450 from petejohanson/urijs-template-parse-parts
urijs: Add URITemplate `parse` and `parts` definitions.
This commit is contained in:
Vendored
+22
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user