10 examples of 'javascript get base url' in JavaScript

Every line of 'javascript get base url' 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
this disclaimer
106function getScriptUrl(prefix, scriptName) {
107 return prefix + scriptName;
108}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

1563value: function getUrl(base) {
1564 var root = IS_SAFARI ? base || window.location.href : "";
1565 return "url(" + root + "#" + this.el.id + ")";
1566}
146function getBaseURL(url) {
147 return ('' + url).replace(/^((?:https?|file|ftp):\/\/.+)\/[^/]+$/, '$1') + '/';
148}
146function getBaseURL(url) {
147 return ('' + url).replace(/^((?:https?|file|ftp|chrome-extension|moz-extension):\/\/.+)\/[^/]+$/, '$1') + '/';
148}
1export default function getBaseUrl() {
2 return getQueryStringParameterByName("useMockApi")
3 ? "http://localhost:3001/"
4 : "/";
5}
7export function getUrl(url) {
8 return config.base + url;
9}
20function getBaseUrl(url = window.location) {
21 return url.protocol + '//' + url.host + '/' + url.pathname.split('/')[1];
22}
86function getBaseURL(url) {
87 if(typeof url === 'string') {
88 url = url.substr(0, url.lastIndexOf('/') + 1);
89 }
90
91 return url;
92}
64function _getLoadUrl(code) {
65 return this.contextPath + 'workflow/flow/define/viewxml/'+ code +'/000';
66}
6function baseUrl(permalink) {
7 var siteUrl = $('body').data('baseurl');
8 var permalink = permalink || '';
9
10 return siteUrl + permalink;
11}

Related snippets