Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
SemWeb
libview
Commits
fa40a82c3a83
Commit
9deae1be
authored
Dec 21, 2018
by
Laurent Wouters
Browse files
[test] Support custom callback for URI probing
parent
d53e8b7a3e22
Changes
1
Hide whitespace changes
Inline
Side-by-side
libview/src/application.ts
View file @
fa40a82c
...
...
@@ -159,6 +159,19 @@ export function sameResources(first: Resource, second: Resource): boolean {
* @param resource The resource
*/
export
function
probeResource
(
resource
:
Resource
):
Promise
<
Resource
>
{
return
probeResourceWith
(
resource
,
probeResourceUri
);
}
/**
* Probes the different URIs for a resource and remove the dead ones
* Returns a promise for clean version of the resource
* @param resource The resource
* @param probe The probe function to use
*/
export
function
probeResourceWith
(
resource
:
Resource
,
probe
:
(
uri
:
string
)
=>
Promise
<
string
>
):
Promise
<
Resource
>
{
return
new
Promise
<
Resource
>
(
(
resolve
:
(
result
:
Resource
)
=>
void
,
reject
:
(
reason
:
any
)
=>
void
)
=>
{
let
remaining
:
String
[]
=
[];
...
...
@@ -187,9 +200,9 @@ export function probeResource(resource: Resource): Promise<Resource> {
* Probes an URI for a resource to check whether it is valid
* @param uri An URI
*/
function
probeResourceUri
(
uri
:
string
):
Promise
<
S
tring
>
{
return
new
Promise
<
S
tring
>
(
(
resolve
:
(
result
:
S
tring
)
=>
void
,
reject
:
(
reason
:
any
)
=>
void
)
=>
{
function
probeResourceUri
(
uri
:
string
):
Promise
<
s
tring
>
{
return
new
Promise
<
s
tring
>
(
(
resolve
:
(
result
:
s
tring
)
=>
void
,
reject
:
(
reason
:
any
)
=>
void
)
=>
{
let
xmlHttp
=
new
XMLHttpRequest
();
xmlHttp
.
onreadystatechange
=
function
()
{
if
(
xmlHttp
.
readyState
===
4
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment