mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:16:41 +08:00
FIX: Only unregister service workers that belongs to Discourse.
This commit is contained in:
parent
03169401ff
commit
abbc639e0d
|
@ -82,7 +82,8 @@ export default Ember.Controller.extend({
|
|||
actions: {
|
||||
save() {
|
||||
this.set("saved", false);
|
||||
const url = extractDomainFromUrl(this.get("model.payload_url"));
|
||||
const url = this.get("model.payload_url");
|
||||
const domain = extractDomainFromUrl(url);
|
||||
const model = this.get("model");
|
||||
const isNew = model.get("isNew");
|
||||
|
||||
|
@ -103,10 +104,10 @@ export default Ember.Controller.extend({
|
|||
};
|
||||
|
||||
if (
|
||||
url === "localhost" ||
|
||||
url.match(/192\.168\.\d+\.\d+/) ||
|
||||
url.match(/127\.\d+\.\d+\.\d+/) ||
|
||||
url === Discourse.BaseUrl
|
||||
domain === "localhost" ||
|
||||
domain.match(/192\.168\.\d+\.\d+/) ||
|
||||
domain.match(/127\.\d+\.\d+\.\d+/) ||
|
||||
url.startsWith(Discourse.BaseUrl)
|
||||
) {
|
||||
return bootbox.confirm(
|
||||
I18n.t("admin.web_hooks.warn_local_payload_url"),
|
||||
|
|
|
@ -20,7 +20,7 @@ export default {
|
|||
Discourse.ServiceWorkerURL
|
||||
)
|
||||
) {
|
||||
registration.unregister();
|
||||
this.unregister(registration);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -34,10 +34,16 @@ export default {
|
|||
} else {
|
||||
navigator.serviceWorker.getRegistrations().then(registrations => {
|
||||
for (let registration of registrations) {
|
||||
registration.unregister();
|
||||
this.unregister(registration);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
unregister(registration) {
|
||||
if (registration.scope.startsWith(Discourse.BaseUrl)) {
|
||||
registration.unregister();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -443,11 +443,10 @@ module ApplicationHelper
|
|||
|
||||
def client_side_setup_data
|
||||
service_worker_url = Rails.env.development? ? 'service-worker.js' : Rails.application.assets_manifest.assets['service-worker.js']
|
||||
current_hostname_without_port = RailsMultisite::ConnectionManagement.current_hostname.sub(/:[\d]*$/, '')
|
||||
|
||||
setup_data = {
|
||||
cdn: Rails.configuration.action_controller.asset_host,
|
||||
base_url: current_hostname_without_port,
|
||||
base_url: Discourse.base_url,
|
||||
base_uri: Discourse::base_uri,
|
||||
environment: Rails.env,
|
||||
letter_avatar_version: LetterAvatar.version,
|
||||
|
|
|
@ -115,7 +115,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.BaseUrl = "localhost";
|
||||
Discourse.BaseUrl = "http://localhost:3000";
|
||||
Discourse.Session.resetCurrent();
|
||||
Discourse.User.resetCurrent();
|
||||
resetSite(Discourse.SiteSettings);
|
||||
|
|
Loading…
Reference in New Issue
Block a user