Skip to content

Commit

Permalink
ecmascript: Add url.resolve()
Browse files Browse the repository at this point in the history
  • Loading branch information
andoma committed Feb 1, 2017
1 parent cbac12f commit d473396
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions res/ecmascript/modules/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ exports.format = function(d) {

exports.parse = string.parseURL;

exports.resolve = string.resolveURL;

15 changes: 15 additions & 0 deletions src/ecmascript/es_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ es_parseURL(duk_context *ctx)
}


/**
*
*/
static int
es_resolveURL(duk_context *ctx)
{
const char *base = duk_require_string(ctx, 0);
const char *url = duk_require_string(ctx, 1);
char *newurl = url_resolve_relative_from_base(base, url);
duk_push_string(ctx, newurl);
free(newurl);
return 1;
}


static const duk_function_list_entry fnlist_string[] = {
{ "isUtf8", es_is_utf8_duk, 1 },
Expand All @@ -370,6 +384,7 @@ static const duk_function_list_entry fnlist_string[] = {
{ "durationToString", es_durationtostring, 1 },
{ "parseTime", es_parseTime, 1 },
{ "parseURL", es_parseURL, 2 },
{ "resolveURL", es_resolveURL, 2 },
{ NULL, NULL, 0}
};

Expand Down

0 comments on commit d473396

Please sign in to comment.