Index: runtime/vm/dart_api_impl.cc |
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
index 5d5a531508229bd64f02dfc9ff37d330fe37ba18..002d334e261df3cddaf1474342b105456085af1a 100644 |
--- a/runtime/vm/dart_api_impl.cc |
+++ b/runtime/vm/dart_api_impl.cc |
@@ -42,6 +42,7 @@ |
#include "vm/timeline.h" |
#include "vm/timer.h" |
#include "vm/unicode.h" |
+#include "vm/uri.h" |
#include "vm/verifier.h" |
#include "vm/version.h" |
@@ -5168,6 +5169,31 @@ DART_EXPORT Dart_Handle Dart_SetLibraryTagHandler( |
} |
+DART_EXPORT Dart_Handle Dart_DefaultCanonicalizeUrl(Dart_Handle library, |
+ Dart_Handle url) { |
+ API_TIMELINE_DURATION; |
+ DARTSCOPE(Thread::Current()); |
+ CHECK_CALLBACK_STATE(T); |
+ |
+ const Library& lib = Api::UnwrapLibraryHandle(Z, library); |
+ if (lib.IsNull()) { |
+ RETURN_TYPE_ERROR(Z, library, Library); |
+ } |
+ const String& uri = Api::UnwrapStringHandle(Z, url); |
+ if (uri.IsNull()) { |
+ RETURN_TYPE_ERROR(Z, url, String); |
+ } |
+ |
+ const String& lib_uri = String::Handle(Z, lib.url()); |
+ const char* resolved_uri; |
+ if (!ResolveUri(uri.ToCString(), lib_uri.ToCString(), &resolved_uri)) { |
+ return Api::NewError("%s: Unable to canonicalize uri '%s'.", |
+ CURRENT_FUNC, uri.ToCString()); |
+ } |
+ return Api::NewHandle(T, String::New(resolved_uri)); |
+} |
+ |
+ |
// NOTE: Need to pass 'result' as a parameter here in order to avoid |
// warning: variable 'result' might be clobbered by 'longjmp' or 'vfork' |
// which shows up because of the use of setjmp. |