@@ -13,6 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { posix as posixPath } from 'path';
|
||||
import {
|
||||
TemplateEntityV1alpha1,
|
||||
LOCATION_ANNOTATION,
|
||||
@@ -53,3 +55,20 @@ export const parseLocationAnnotation = (
|
||||
location,
|
||||
};
|
||||
};
|
||||
|
||||
export function joinGitUrlPath(repoUrl: string, path?: string): string {
|
||||
const parsed = new URL(repoUrl);
|
||||
|
||||
if (parsed.hostname.endsWith('azure.com')) {
|
||||
const templatePath = posixPath.normalize(
|
||||
posixPath.join(
|
||||
posixPath.dirname(parsed.searchParams.get('path') || '/'),
|
||||
path || '.',
|
||||
),
|
||||
);
|
||||
parsed.searchParams.set('path', templatePath);
|
||||
return parsed.toString();
|
||||
}
|
||||
|
||||
return new URL(path || '.', repoUrl).toString().replace(/\/$/, '');
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
TemplaterValues,
|
||||
PublisherBuilder,
|
||||
parseLocationAnnotation,
|
||||
joinGitUrlPath,
|
||||
FilePreparer,
|
||||
} from '../scaffolder';
|
||||
import { CatalogEntityClient } from '../lib/catalog';
|
||||
@@ -138,12 +139,10 @@ export async function createRouter(
|
||||
|
||||
const preparer = preparers.get(templateEntityLocation);
|
||||
|
||||
const url = new URL(
|
||||
template.spec.path || '.',
|
||||
const url = joinGitUrlPath(
|
||||
templateEntityLocation,
|
||||
)
|
||||
.toString()
|
||||
.replace(/\/$/, '');
|
||||
template.spec.path,
|
||||
);
|
||||
|
||||
await preparer.prepare({
|
||||
url,
|
||||
|
||||
Reference in New Issue
Block a user