ui: Amends to the data-sink service/component (#7740)

1. Fix conditional typo
2. Code style changes
3. Don't use URL for parsing, Safari only likes http like URLs
This commit is contained in:
John Cowen 2020-05-01 09:49:33 +01:00 committed by John Cowen
parent dd6506e994
commit 067ed448e3
3 changed files with 5 additions and 16 deletions

View File

@ -17,8 +17,7 @@ export default Service.extend({
instance = repo.peek(slug);
}
}
setProperties(instance, data);
return instance;
return setProperties(instance, data);
},
persist: function(sink, instance) {
const [, , , /*dc*/ /*nspace*/ model] = sink.split('/');

View File

@ -3,12 +3,11 @@ import { setProperties } from '@ember/object';
export default Service.extend({
settings: service('settings'),
prepare: function(sink, data, instance) {
if (data === null || data || '') {
prepare: function(sink, data, instance = {}) {
if (data === null || data === '') {
return instance;
}
setProperties(instance, data);
return instance;
return setProperties(instance, data);
},
persist: function(sink, instance) {
const slug = sink.split(':').pop();

View File

@ -1,16 +1,7 @@
import Service, { inject as service } from '@ember/service';
const parts = function(uri) {
if (uri.indexOf('://') === -1) {
uri = `data://${uri}`;
}
const url = new URL(uri);
let pathname = url.pathname;
if (pathname.startsWith('//')) {
pathname = pathname.substr(2);
}
const providerName = url.protocol.substr(0, url.protocol.length - 1);
return [providerName, pathname];
return uri.split('://');
};
export default Service.extend({
data: service('data-sink/protocols/http'),