Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: third_party/WebKit/Source/core/dom/Modulator.cpp

Issue 2640723002: [ES6 modules] Implement https://html.spec.whatwg.org/#resolve-a-module-specifier (Closed)
Patch Set: yhirano review2 Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Modulator.cpp
diff --git a/third_party/WebKit/Source/core/dom/Modulator.cpp b/third_party/WebKit/Source/core/dom/Modulator.cpp
index c523d831ef8089beadc06462ad4b2496857a543a..58dc787c332ea5a7bdb1d2c39b56bb9e0439f74f 100644
--- a/third_party/WebKit/Source/core/dom/Modulator.cpp
+++ b/third_party/WebKit/Source/core/dom/Modulator.cpp
@@ -16,4 +16,30 @@ Modulator* Modulator::from(LocalFrame* frame) {
return scriptState->perContextData()->modulator();
}
+KURL Modulator::resolveModuleSpecifier(const String& moduleRequest,
+ const KURL& baseURL) {
+ // Step 1. Apply the URL parser to specifier. If the result is not failure,
+ // return the result.
+ KURL url(KURL(), moduleRequest);
+ if (url.isValid())
+ return url;
+
+ // Step 2. If specifier does not start with the character U+002F SOLIDUS (/),
+ // the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./), or the
+ // three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F SOLIDUS
+ // (../), return failure and abort these steps.
+ if (!moduleRequest.startsWith("/") && !moduleRequest.startsWith("./") &&
+ !moduleRequest.startsWith("../"))
+ return KURL();
+
+ // Step 3. Return the result of applying the URL parser to specifier with
+ // script's base URL as the base URL.
+ DCHECK(baseURL.isValid());
+ KURL absoluteURL(baseURL, moduleRequest);
+ if (absoluteURL.isValid())
+ return absoluteURL;
+
+ return KURL();
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/dom/Modulator.h ('k') | third_party/WebKit/Source/core/dom/ModulatorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698