10 examples of 'how to get current url in angularjs' in JavaScript

Every line of 'how to get current url in angularjs' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
302function getCurrentPath($scope,$http,path){
303 if(path){
304 var cutLength = ($scope.rootPath).length;
305 var currentPath = path.substring(cutLength,path.length);
306 return currentPath;
307 }else{
308 return "";
309 }
310}
19function read_current_url()
20{
21 mainwp_current_url = document.location.href.replace( /^.*?\/([^/]*?)\/?$/i, '$1' );
22 return mainwp_current_url;
23}
18function getUrl (currentUrl, path) {
19 const pathObject = url.parse(path);
20 if (isUrl(path) && !pathObject.protocol) {
21 const urlObject = url.parse(currentUrl);
22 pathObject.protocol = urlObject.protocol;
23 path = url.format(pathObject);
24 }
25 return url.resolve(currentUrl, path);
26}
380function getCurrentPath() {
381 return this.selectedSidebarItem ? this.selectedSidebarItem.path : '';
382}
83function viewUrl (url) {
84 return 'beaker://editor/' + url.slice('dat://'.length)
85}
20get currentUrl () {
21 return this.location.url();
22}
26function getURL()
27{
28 var url = document.documentURI;
29 var match = url.match(/&u=([^&]+)&/);
30
31 // match == null if not found; if so, return an empty string
32 // instead of what would turn out to be portions of the URI
33 if (!match)
34 return "";
35
36 url = decodeURIComponent(match[1]);
37
38 // If this is a view-source page, then get then real URI of the page
39 if (url.startsWith("view-source:"))
40 url = url.slice(12);
41 return url;
42}
94function getPathURL(url) {
95 if(typeof url === 'string') {
96 var i = url.indexOf('?');
97 if(i > -1) {
98 url = url.substr(0, i);
99 }
100 i = url.indexOf('#');
101 if(i > -1) {
102 url = url.substr(0, i);
103 }
104 }
105
106 return url;
107}
7getUrlWithContextPath(url) {
8 return this.contextPath + url;
9}
194get currentURL() {
195 return this._dataSource.url;
196}

Related snippets