Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract function not detected if the arguments are extracted to a variable #95

Open
mkshiblu opened this issue Mar 29, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mkshiblu
Copy link
Owner

angular/angular.js@0cbc505

EXTRACT | Function

parseAppUrl| src/ng/location.js:821-1500

To
decodePath|src/ng/location.js:590-963

image

image

@mkshiblu mkshiblu added the bug Something isn't working label Mar 29, 2021
@mkshiblu mkshiblu self-assigned this Apr 1, 2021
@mkshiblu mkshiblu added the In progress Currently doing label Apr 1, 2021
@mkshiblu
Copy link
Owner Author

mkshiblu commented Apr 1, 2021

Not reported by RM either when re-created with Java version-

Java V1

public class V {

	static class Location {
		String $$path;
	}

	void parseAppUrl(String url, Location locationObj) {
		boolean prefixed = (url.charAt(0) != '/');
		if (prefixed) {
			url = '/' + url;
		}
		
		ResolvedUrl match = urlResolve(url);
		
		locationObj.$$path = decodeURIComponent(prefixed && match.pathname.charAt(0) == '/' ?
				match.pathname.substring(1) : match.pathname);
	}
}

Java v2

public class V {

	static class Location {
		String $$path;
	}

	String decodePath(String path, boolean html5Mode) {
		String[] segments = path.split("/");
		int i = segments.length;

		while (i-- > 0) {
			segments[i] = decodeURIComponent(segments[i]);
			if (html5Mode) {
				// encode forward slashes to prevent them from being mistaken for path
				// separators
				segments[i] = segments[i].replace("", "");
			}
		}

		return String.join("/", segments);
	}

	void parseAppUrl(String url, Location locationObj, boolean html5Mode) {
		boolean prefixed = (url.charAt(0) != '/');
		if (prefixed) {
			url = '/' + url;
		}

		ResolvedUrl match = urlResolve(url);

		String path = prefixed && match.pathname.charAt(0) == '/' ? match.pathname.substring(1) : match.pathname;
		locationObj.$$path = decodePath(path, html5Mode);
	}
}

@mkshiblu mkshiblu removed the In progress Currently doing label May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant