class AutomaticDispatcherUrlService implements DispatcherUrlService {

	@Override
	public String localize(String externalUrl) {
		String localBase = getLocalDispatcherUrl();
		String dispatcherBase = getDispatcherUrl();
		if (externalUrl.startsWith(dispatcherBase)) {
			return localBase + externalUrl.substring(dispatcherBase.length());
		} else {
			// not a dispatcher url, return the original one
			return externalUrl;
		}
	}

}