diff --git a/Sources/Configuration/ConfigKey.swift b/Sources/Configuration/ConfigKey.swift index ca12780..a120410 100644 --- a/Sources/Configuration/ConfigKey.swift +++ b/Sources/Configuration/ConfigKey.swift @@ -182,13 +182,23 @@ extension AbsoluteConfigKey { /// Returns a new absolute configuration key by prepending the given relative key. /// - Parameter prefix: The relative configuration key to prepend to this key. /// - Returns: A new absolute configuration key with the prefix prepended. - internal func prepending(_ prefix: ConfigKey) -> AbsoluteConfigKey { + public func prepending(_ prefix: ConfigKey) -> AbsoluteConfigKey { var prefixedComponents = prefix.components prefixedComponents.append(contentsOf: self.components) var mergedContext = prefix.context mergedContext.merge(self.context) { $1 } return AbsoluteConfigKey(prefixedComponents, context: mergedContext) } + + /// Returns a new absolute configuration key by appending the given relative key. + /// - Parameter relative: The relative configuration key to append to this key. + /// - Returns: A new absolute configuration key with the relative key appended. + public func appending(_ relative: ConfigKey) -> AbsoluteConfigKey { + var appended = self + appended.components.append(contentsOf: relative.components) + appended.context.merge(relative.context) { $1 } + return appended + } } extension AbsoluteConfigKey: ExpressibleByArrayLiteral {