| 18 | : _resourceId(std::move(resourceId)), _symbolName(std::move(symbolName)) {} |
| 19 | |
| 20 | ComponentPath ComponentPath::parse(const StringBox& componentPathString) { |
| 21 | static constexpr char targetSuffix[] = ".valdi"; |
| 22 | if (componentPathString.hasSuffix(targetSuffix)) { |
| 23 | // Backward compatibility |
| 24 | return parse(componentPathString |
| 25 | .substring(0, componentPathString.length() - std::string::traits_type::length(targetSuffix)) |
| 26 | .append(".vue.generated") |
| 27 | .prepend("ComponentClass@")); |
| 28 | } |
| 29 | |
| 30 | StringBox resolvedSymbolName; |
| 31 | StringBox resolvedComponentPath; |
| 32 | |
| 33 | auto symbolSeparator = componentPathString.indexOf('@'); |
| 34 | if (symbolSeparator) { |
| 35 | auto parts = componentPathString.split(*symbolSeparator); |
| 36 | resolvedSymbolName = std::move(parts.first); |
| 37 | resolvedComponentPath = std::move(parts.second); |
| 38 | } else { |
| 39 | resolvedComponentPath = componentPathString; |
| 40 | } |
| 41 | |
| 42 | auto result = JavaScriptPathResolver::resolveResourceId(resolvedComponentPath); |
| 43 | if (!result) { |
| 44 | return ComponentPath(); |
| 45 | } |
| 46 | return ComponentPath(result.moveValue(), std::move(resolvedSymbolName)); |
| 47 | } |
| 48 | |
| 49 | const ResourceId& ComponentPath::getResourceId() const { |
| 50 | return _resourceId; |