mirror of
https://github.com/discourse/discourse.git
synced 2025-01-30 17:07:14 +08:00
FIX: Discourse.BaseUri should not default to /
This commit is contained in:
parent
f6380c66ef
commit
aca70805f1
|
@ -16,13 +16,10 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
|
||||||
// if it's a non relative URL, return it.
|
// if it's a non relative URL, return it.
|
||||||
if (!/^\/[^\/]/.test(url)) return url;
|
if (!/^\/[^\/]/.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);
|
return Discourse.BaseUri + url;
|
||||||
if (url.indexOf(u) !== -1) return url;
|
|
||||||
if (u.length > 0 && url[0] !== "/") url = "/" + url;
|
|
||||||
|
|
||||||
return u + url;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getURLWithCDN: function(url) {
|
getURLWithCDN: function(url) {
|
||||||
|
|
|
@ -62,11 +62,9 @@ const DiscourseLocation = Ember.Object.extend({
|
||||||
*/
|
*/
|
||||||
getURL() {
|
getURL() {
|
||||||
const location = get(this, 'location');
|
const location = get(this, 'location');
|
||||||
let rootURL = (Discourse.BaseUri === undefined ? "/" : Discourse.BaseUri);
|
|
||||||
let url = location.pathname;
|
let url = location.pathname;
|
||||||
|
|
||||||
rootURL = rootURL.replace(/\/$/, '');
|
url = url.replace(Discourse.BaseUri, '');
|
||||||
url = url.replace(rootURL, '');
|
|
||||||
|
|
||||||
const search = location.search || '';
|
const search = location.search || '';
|
||||||
url += 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({
|
const BareRouter = Ember.Router.extend({
|
||||||
rootURL,
|
rootURL,
|
||||||
|
|
|
@ -61,7 +61,7 @@ class AdminDashboardData
|
||||||
:failing_emails_check, :default_logo_check, :contact_email_check,
|
:failing_emails_check, :default_logo_check, :contact_email_check,
|
||||||
:send_consumer_email_check, :title_check,
|
:send_consumer_email_check, :title_check,
|
||||||
:site_description_check, :site_contact_username_check,
|
:site_description_check, :site_contact_username_check,
|
||||||
:notification_email_check
|
:notification_email_check, :subfolder_ends_in_slash_check
|
||||||
|
|
||||||
add_problem_check do
|
add_problem_check do
|
||||||
sidekiq_check || queue_size_check
|
sidekiq_check || queue_size_check
|
||||||
|
@ -200,4 +200,8 @@ class AdminDashboardData
|
||||||
I18n.t('dashboard.ruby_version_warning') if RUBY_VERSION == '2.0.0' and RUBY_PATCHLEVEL < 247
|
I18n.t('dashboard.ruby_version_warning') if RUBY_VERSION == '2.0.0' and RUBY_PATCHLEVEL < 247
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def subfolder_ends_in_slash_check
|
||||||
|
I18n.t('dashboard.subfolder_ends_in_slash') if Discourse.base_uri =~ /\/$/
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<script>
|
<script>
|
||||||
Discourse.CDN = '<%= Rails.configuration.action_controller.asset_host %>';
|
Discourse.CDN = '<%= Rails.configuration.action_controller.asset_host %>';
|
||||||
Discourse.BaseUrl = '<%= RailsMultisite::ConnectionManagement.current_hostname %>'.replace(/:[\d]*$/,"");
|
Discourse.BaseUrl = '<%= RailsMultisite::ConnectionManagement.current_hostname %>'.replace(/:[\d]*$/,"");
|
||||||
Discourse.BaseUri = '<%= Discourse::base_uri "/" %>';
|
Discourse.BaseUri = '<%= Discourse::base_uri %>';
|
||||||
Discourse.Environment = '<%= Rails.env %>';
|
Discourse.Environment = '<%= Rails.env %>';
|
||||||
Discourse.SiteSettings = PreloadStore.get('siteSettings');
|
Discourse.SiteSettings = PreloadStore.get('siteSettings');
|
||||||
Discourse.LetterAvatarVersion = '<%= LetterAvatar.version %>';
|
Discourse.LetterAvatarVersion = '<%= LetterAvatar.version %>';
|
||||||
|
|
|
@ -727,6 +727,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."
|
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>."
|
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>."
|
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:
|
content_types:
|
||||||
education_new_reply:
|
education_new_reply:
|
||||||
|
|
|
@ -129,7 +129,7 @@ module PrettyText
|
||||||
def self.decorate_context(context)
|
def self.decorate_context(context)
|
||||||
context.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
|
context.eval("Discourse.CDN = '#{Rails.configuration.action_controller.asset_host}';")
|
||||||
context.eval("Discourse.BaseUrl = '#{RailsMultisite::ConnectionManagement.current_hostname}'.replace(/:[\d]*$/,'');")
|
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.SiteSettings = #{SiteSetting.client_settings_json};")
|
||||||
|
|
||||||
context.eval("Discourse.getURL = function(url) {
|
context.eval("Discourse.getURL = function(url) {
|
||||||
|
|
|
@ -98,7 +98,7 @@ test("url", function() {
|
||||||
t = testClass.create({ username: 'eviltrout' });
|
t = testClass.create({ username: 'eviltrout' });
|
||||||
equal(t.get('userUrl'), "/users/eviltrout", "it supports urls without a prefix");
|
equal(t.get('userUrl'), "/users/eviltrout", "it supports urls without a prefix");
|
||||||
|
|
||||||
Discourse.BaseUri = "/prefixed/";
|
Discourse.BaseUri = "/prefixed";
|
||||||
t = testClass.create({ username: 'eviltrout' });
|
t = testClass.create({ username: 'eviltrout' });
|
||||||
equal(t.get('userUrl'), "/prefixed/users/eviltrout", "it supports urls with a prefix");
|
equal(t.get('userUrl'), "/prefixed/users/eviltrout", "it supports urls with a prefix");
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,7 +91,7 @@ QUnit.testStart(function(ctx) {
|
||||||
|
|
||||||
// Allow our tests to change site settings and have them reset before the next test
|
// Allow our tests to change site settings and have them reset before the next test
|
||||||
Discourse.SiteSettings = dup(Discourse.SiteSettingsOriginal);
|
Discourse.SiteSettings = dup(Discourse.SiteSettingsOriginal);
|
||||||
Discourse.BaseUri = "/";
|
Discourse.BaseUri = "";
|
||||||
Discourse.BaseUrl = "localhost";
|
Discourse.BaseUrl = "localhost";
|
||||||
Discourse.Session.resetCurrent();
|
Discourse.Session.resetCurrent();
|
||||||
Discourse.User.resetCurrent();
|
Discourse.User.resetCurrent();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user