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 namespace blink { |
| 8 |
| 9 KURL Modulator::resolveModuleSpecifier(const String& moduleRequest, |
| 10 const KURL& baseURL) { |
| 11 // Step 1. Apply the URL parser to specifier. If the result is not failure, |
| 12 // return the result. |
| 13 KURL url(KURL(), moduleRequest); |
| 14 if (url.isValid()) |
| 15 return url; |
| 16 |
| 17 // Step 2. If specifier does not start with the character U+002F SOLIDUS (/), |
| 18 // the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./), or the |
| 19 // three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F SOLIDUS |
| 20 // (../), return failure and abort these steps. |
| 21 if (!moduleRequest.startsWith("/") && !moduleRequest.startsWith("./") && |
| 22 !moduleRequest.startsWith("../")) |
| 23 return KURL(); |
| 24 |
| 25 // Step 3. Return the result of applying the URL parser to specifier with |
| 26 // script's base URL as the base URL. |
| 27 DCHECK(baseURL.isValid()); |
| 28 KURL relativeURL(baseURL, moduleRequest); |
| 29 if (relativeURL.isValid()) |
| 30 return relativeURL; |
| 31 |
| 32 return KURL(); |
| 33 } |
| 34 |
| 35 } // namespace blink |
OLD | NEW |