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:
parent
c8ecb8db3b
commit
02a2d0a0be
|
@ -17,8 +17,7 @@ export default Service.extend({
|
||||||
instance = repo.peek(slug);
|
instance = repo.peek(slug);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setProperties(instance, data);
|
return setProperties(instance, data);
|
||||||
return instance;
|
|
||||||
},
|
},
|
||||||
persist: function(sink, instance) {
|
persist: function(sink, instance) {
|
||||||
const [, , , /*dc*/ /*nspace*/ model] = sink.split('/');
|
const [, , , /*dc*/ /*nspace*/ model] = sink.split('/');
|
||||||
|
|
|
@ -3,12 +3,11 @@ import { setProperties } from '@ember/object';
|
||||||
|
|
||||||
export default Service.extend({
|
export default Service.extend({
|
||||||
settings: service('settings'),
|
settings: service('settings'),
|
||||||
prepare: function(sink, data, instance) {
|
prepare: function(sink, data, instance = {}) {
|
||||||
if (data === null || data || '') {
|
if (data === null || data === '') {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
setProperties(instance, data);
|
return setProperties(instance, data);
|
||||||
return instance;
|
|
||||||
},
|
},
|
||||||
persist: function(sink, instance) {
|
persist: function(sink, instance) {
|
||||||
const slug = sink.split(':').pop();
|
const slug = sink.split(':').pop();
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
import Service, { inject as service } from '@ember/service';
|
import Service, { inject as service } from '@ember/service';
|
||||||
|
|
||||||
const parts = function(uri) {
|
const parts = function(uri) {
|
||||||
if (uri.indexOf('://') === -1) {
|
return uri.split('://');
|
||||||
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];
|
|
||||||
};
|
};
|
||||||
export default Service.extend({
|
export default Service.extend({
|
||||||
data: service('data-sink/protocols/http'),
|
data: service('data-sink/protocols/http'),
|
||||||
|
|
Loading…
Reference in New Issue