Merge pull request #3735 from riking/patch-4
FIX: Discourse.BaseUri should not default to /
This commit is contained in:
commit
8ba7c06b7d
|
@ -16,13 +16,10 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
|||
// if it's a non relative URL, return it.
|
||||
if (url !== '/' && !/^\/[^\/]/.test(url)) return url;
|
||||
|
||||
var u = Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri;
|
||||
if (url.indexOf(Discourse.BaseUri) !== -1) return url;
|
||||
if (url[0] !== "/") url = "/" + url;
|
||||
|
||||
if (u[u.length-1] === '/') u = u.substring(0, u.length-1);
|
||||
if (url.indexOf(u) !== -1) return url;
|
||||
if (u.length > 0 && url[0] !== "/") url = "/" + url;
|
||||
|
||||
return u + url;
|
||||
return Discourse.BaseUri + url;
|
||||
},
|
||||
|
||||
getURLWithCDN: function(url) {
|
||||
|
|
|
@ -62,11 +62,9 @@ const DiscourseLocation = Ember.Object.extend({
|
|||
*/
|
||||
getURL() {
|
||||
const location = get(this, 'location');
|
||||
let rootURL = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri);
|
||||
let url = location.pathname;
|
||||
|
||||
rootURL = rootURL.replace(/\/$/, '');
|
||||
url = url.replace(rootURL, '');
|
||||
url = url.replace(Discourse.BaseUri, '');
|
||||
|
||||
const search = location.search || '';
|
||||
url += search;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const rootURL = Discourse.BaseUri && Discourse.BaseUri !== "/" ? Discourse.BaseUri : undefined;
|
||||
const rootURL = Discourse.BaseUri;
|
||||
|
||||
const BareRouter = Ember.Router.extend({
|
||||
rootURL,
|
||||
|
|
|
@ -62,7 +62,7 @@ class AdminDashboardData
|
|||
:failing_emails_check, :default_logo_check, :contact_email_check,
|
||||
:send_consumer_email_check, :title_check,
|
||||
:site_description_check, :site_contact_username_check,
|
||||
:notification_email_check
|
||||
:notification_email_check, :subfolder_ends_in_slash_check
|
||||
|
||||
add_problem_check do
|
||||
sidekiq_check || queue_size_check
|
||||
|
@ -201,4 +201,8 @@ class AdminDashboardData
|
|||
I18n.t('dashboard.ruby_version_warning') if RUBY_VERSION == '2.0.0' and RUBY_PATCHLEVEL < 247
|
||||
end
|
||||
|
||||
def subfolder_ends_in_slash_check
|
||||
I18n.t('dashboard.subfolder_ends_in_slash') if Discourse.base_uri =~ /\/$/
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<script>
|
||||
Discourse.CDN = '<%= Rails.configuration.action_controller.asset_host %>';
|
||||
Discourse.BaseUrl = '<%= RailsMultisite::ConnectionManagement.current_hostname %>'.replace(/:[\d]*$/,"");
|
||||
Discourse.BaseUri = '<%= Discourse::base_uri "/" %>';
|
||||
Discourse.BaseUri = '<%= Discourse::base_uri %>';
|
||||
Discourse.Environment = '<%= Rails.env %>';
|
||||
Discourse.SiteSettings = PreloadStore.get('siteSettings');
|
||||
Discourse.LetterAvatarVersion = '<%= LetterAvatar.version %>';
|
||||
|
|
|
@ -744,6 +744,7 @@ en:
|
|||
consumer_email_warning: "Your site is configured to use Gmail (or another consumer email service) to send email. <a href='http://support.google.com/a/bin/answer.py?hl=en&answer=166852' target='_blank'>Gmail limits how many emails you can send</a>. Consider using an email service provider like mandrill.com to ensure email deliverability."
|
||||
site_contact_username_warning: "Enter the name of a friendly staff user account to send important automated messages from. Update site_contact_username in <a href='/admin/site_settings'>Site Settings</a>."
|
||||
notification_email_warning: "Notification emails are not being sent from a valid email address on your domain; email delivery will be erratic and unreliable. Please set notification_email to a valid local email address in <a href='/admin/site_settings'>Site Settings</a>."
|
||||
subfolder_ends_in_slash: "Your subfolder setup is incorrect; the DISCOURSE_RELATIVE_URL_ROOT ends in a slash."
|
||||
|
||||
content_types:
|
||||
education_new_reply:
|
||||
|
|
|
@ -141,7 +141,7 @@ module PrettyText
|
|||
def self.decorate_context(context)
|
||||
context.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
|
||||
context.eval("Discourse.BaseUrl = '#{RailsMultisite::ConnectionManagement.current_hostname}'.replace(/:[\d]*$/,'');")
|
||||
context.eval("Discourse.BaseUri = '#{Discourse::base_uri("/")}';")
|
||||
context.eval("Discourse.BaseUri = '#{Discourse::base_uri}';")
|
||||
context.eval("Discourse.SiteSettings = #{SiteSetting.client_settings_json};")
|
||||
|
||||
context.eval("Discourse.getURL = function(url) {
|
||||
|
|
|
@ -98,7 +98,7 @@ test("url", function() {
|
|||
t = testClass.create({ username: 'eviltrout' });
|
||||
equal(t.get('userUrl'), "/users/eviltrout", "it supports urls without a prefix");
|
||||
|
||||
Discourse.BaseUri = "/prefixed/";
|
||||
Discourse.BaseUri = "/prefixed";
|
||||
t = testClass.create({ username: 'eviltrout' });
|
||||
equal(t.get('userUrl'), "/prefixed/users/eviltrout", "it supports urls with a prefix");
|
||||
});
|
||||
|
|
|
@ -88,7 +88,7 @@ QUnit.testStart(function(ctx) {
|
|||
|
||||
// Allow our tests to change site settings and have them reset before the next test
|
||||
Discourse.SiteSettings = dup(Discourse.SiteSettingsOriginal);
|
||||
Discourse.BaseUri = "/";
|
||||
Discourse.BaseUri = "";
|
||||
Discourse.BaseUrl = "localhost";
|
||||
Discourse.Session.resetCurrent();
|
||||
Discourse.User.resetCurrent();
|
||||
|
|
Loading…
Reference in New Issue