function normalize(sResourceName, sBaseName) {

		const p = sResourceName.search(rDotSegmentAnywhere);

		// check whether the name needs to be resolved at all - if not, just return the sModuleName as it is.
		if ( p < 0 ) {
			return sResourceName;
		}

		// if the name starts with a relative segment then there must be a base name (a global sap.ui.require doesn't support relative names)
		if ( p === 0 ) {
			if ( sBaseName == null ) {
				throw new Error("relative name not supported ('" + sResourceName + "'");
			}
			// prefix module name with the parent package
			sResourceName = sBaseName.slice(0, sBaseName.lastIndexOf('/') + 1) + sResourceName;
		}

		const aSegments = sResourceName.split('/');

		// process path segments
		let j = 0;
		const l = aSegments.length;
		for (let i = 0; i < l; i++) {

			const sSegment = aSegments[i];

			if ( rDotSegment.test(sSegment) ) {
				if (sSegment === '.' || sSegment === '') {
					// ignore '.' as it's just a pointer to current package. ignore '' as it results from double slashes (ignored by browsers as well)
					continue;
				} else if (sSegment === '..') {
					// move to parent directory
					if ( j === 0 ) {
						throw new Error("Can't navigate to parent of root ('" + sResourceName + "')");
					}
					j--;
				} else {
					throw new Error("Illegal path segment '" + sSegment + "' ('" + sResourceName + "')");
				}
			} else {
				aSegments[j++] = sSegment;
			}

		}

		aSegments.length = j;

		return aSegments.join('/');
	}
Normalizes a resource name by resolving any relative name segments.

A segment consisting of a single dot <code>./</code>, when used at the beginning of a name refers
to the containing package of the <code>sBaseName</code>. When used inside a name, it is ignored.

A segment consisting of two dots <code>../</code> refers to the parent package. It can be used
anywhere in a name, but the resolved name prefix up to that point must not be empty.

Example: A name <code>../common/validation.js</code> defined in <code>sap/myapp/controller/mycontroller.controller.js</code>
will resolve to <code>sap/myapp/common/validation.js</code>.

When <code>sBaseName</code> is <code>null</code> (e.g. for a <code>sap.ui.require</code> call),
the resource name must not start with a relative name segment or an error will be thrown.

@param {string} sResourceName Name to resolve
@param {string|null} sBaseName Name of a reference module relative to which the name will be resolved
@returns {string} Resolved name
@throws {Error} When a relative name should be resolved but not basename is given;
  or when upward navigation (../) is requested on the root level
  or when a name segment consists of 3 or more dots only
@private