Home / Function/ baseService.getURL() — astro Function Reference

baseService.getURL() — astro Function Reference

Architecture documentation for the baseService.getURL() function in service.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  64a4f236_9a48_ff75_7391_455c8e399ae5["baseService.getURL()"]
  f0f55fc4_9c63_b35c_86d8_8eb3e4fa20ee["service.ts"]
  64a4f236_9a48_ff75_7391_455c8e399ae5 -->|defined in| f0f55fc4_9c63_b35c_86d8_8eb3e4fa20ee
  style 64a4f236_9a48_ff75_7391_455c8e399ae5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/assets/services/service.ts lines 357–395

	getURL(options, imageConfig) {
		const searchParams = new URLSearchParams();

		if (isESMImportedImage(options.src)) {
			searchParams.append('href', options.src.src);
		} else if (isRemoteAllowed(options.src, imageConfig)) {
			searchParams.append('href', options.src);
		} else {
			// If it's not an imported image, nor is it allowed using the current domains or remote patterns, we'll just return the original URL
			return options.src;
		}

		const params: Record<string, keyof typeof options> = {
			w: 'width',
			h: 'height',
			q: 'quality',
			f: 'format',
			fit: 'fit',
			position: 'position',
			background: 'background',
		};

		Object.entries(params).forEach(([param, key]) => {
			options[key] && searchParams.append(param, options[key].toString());
		});

		const imageEndpoint = joinPaths(import.meta.env.BASE_URL, imageConfig.endpoint.route);
		let url = `${imageEndpoint}?${searchParams}`;

		// Append assetQueryParams if available (for adapter-level tracking like skew protection)
		if (imageConfig.assetQueryParams) {
			const assetQueryString = imageConfig.assetQueryParams.toString();
			if (assetQueryString) {
				url += '&' + assetQueryString;
			}
		}

		return url;
	},

Domain

Subdomains

Frequently Asked Questions

What does baseService.getURL() do?
baseService.getURL() is a function in the astro codebase, defined in packages/astro/src/assets/services/service.ts.
Where is baseService.getURL() defined?
baseService.getURL() is defined in packages/astro/src/assets/services/service.ts at line 357.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free