 Chromium Code Reviews
 Chromium Code Reviews Issue 2555653002:
  [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation  (Closed)
    
  
    Issue 2555653002:
  [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation  (Closed) 
  | OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "core/dom/Modulator.h" | |
| 6 | |
| 7 #include "bindings/core/v8/ScriptState.h" | |
| 8 #include "bindings/core/v8/V8PerContextData.h" | |
| 9 | |
| 10 namespace blink { | |
| 11 | |
| 12 Modulator* Modulator::from(LocalFrame* frame) { | |
| 13 return ScriptState::forMainWorld(frame)->perContextData()->modulator(); | |
| 14 } | |
| 15 | |
| 16 KURL Modulator::resolveModuleSpecifier(const String& moduleRequest, | |
| 17 const KURL& baseURL) { | |
| 18 // Step 1. Apply the URL parser to specifier. If the result is not failure, | |
| 19 // return the result. | |
| 20 KURL url(KURL(), moduleRequest); | |
| 21 if (url.isValid()) | |
| 22 return url; | |
| 23 | |
| 24 // Step 2. If specifier does not start with the character U+002F SOLIDUS (/), | |
| 25 // the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./), or the | |
| 26 // three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F SOLIDUS | |
| 27 // (../), return failure and abort these steps. | |
| 28 if (!moduleRequest.startsWith("/") && !moduleRequest.startsWith("./") && | |
| 29 !moduleRequest.startsWith("../")) | |
| 30 return KURL(); | |
| 31 | |
| 32 // Step 3. Return the result of applying the URL parser to specifier with | |
| 33 // script's base URL as the base URL. | |
| 34 DCHECK(baseURL.isValid()); | |
| 35 KURL relativeURL(baseURL, moduleRequest); | |
| 
dominicc (has gone to gerrit)
2017/01/11 03:23:48
Not sure about this naming; the moduleRequest look
 | |
| 36 if (relativeURL.isValid()) | |
| 37 return relativeURL; | |
| 38 | |
| 39 return KURL(); | |
| 40 } | |
| 41 | |
| 42 } // namespace blink | |
| OLD | NEW |