mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
One more
This commit is contained in:
@@ -58,11 +58,13 @@ export function getStyleFromBasemapSource(basemap: BasemapSource): Style | strin
|
||||
function expandUrl(url: string): string[] {
|
||||
const urls = [];
|
||||
let match = /\{([a-z])-([a-z])\}/.exec(url);
|
||||
|
||||
if (match) {
|
||||
// char range
|
||||
const startCharCode = match[1].charCodeAt(0);
|
||||
const stopCharCode = match[2].charCodeAt(0);
|
||||
let charCode;
|
||||
|
||||
for (charCode = startCharCode; charCode <= stopCharCode; ++charCode) {
|
||||
urls.push(url.replace(match[0], String.fromCharCode(charCode)));
|
||||
}
|
||||
@@ -74,6 +76,7 @@ function expandUrl(url: string): string[] {
|
||||
if (match) {
|
||||
// number range
|
||||
const stop = parseInt(match[2], 10);
|
||||
|
||||
for (let i = parseInt(match[1], 10); i <= stop; i++) {
|
||||
urls.push(url.replace(match[0], i.toString()));
|
||||
}
|
||||
@@ -85,6 +88,7 @@ function expandUrl(url: string): string[] {
|
||||
if (match) {
|
||||
// csv
|
||||
const subdomains = match[1].split(',');
|
||||
|
||||
for (const subdomain of subdomains) {
|
||||
urls.push(url.replace(match[0], subdomain));
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ export function getGeometryFormatForType(type: Type): GeometryFormat | undefined
|
||||
|
||||
export function getSerializer(options: GeometryOptions): GeoJSONSerializer {
|
||||
const { geometryFormat } = options;
|
||||
|
||||
switch (geometryFormat) {
|
||||
case 'native':
|
||||
case 'geojson':
|
||||
@@ -62,6 +63,7 @@ export function getSerializer(options: GeometryOptions): GeoJSONSerializer {
|
||||
|
||||
export function getGeometryParser(options: GeometryOptions): (geom: any) => AnyGeometry {
|
||||
const { geometryFormat } = options;
|
||||
|
||||
switch (geometryFormat) {
|
||||
case 'native':
|
||||
case 'geojson':
|
||||
|
||||
@@ -4,6 +4,7 @@ import { getJSType } from './get-js-type';
|
||||
|
||||
test('Returns object for relational fields', () => {
|
||||
const relationTypes = ['m2o', 'o2m', 'm2m', 'm2a', 'files', 'translations'];
|
||||
|
||||
for (const special of relationTypes) {
|
||||
expect(
|
||||
getJSType({
|
||||
@@ -21,6 +22,7 @@ test('Returns object for relational fields', () => {
|
||||
|
||||
test('Returns number for numeric fields', () => {
|
||||
const numericTypes = ['bigInteger', 'integer', 'float', 'decimal'];
|
||||
|
||||
for (const fieldType of numericTypes) {
|
||||
expect(
|
||||
getJSType({
|
||||
@@ -35,6 +37,7 @@ test('Returns number for numeric fields', () => {
|
||||
|
||||
test('Returns string for string fields', () => {
|
||||
const stringTypes = ['string', 'text', 'uuid', 'hash'];
|
||||
|
||||
for (const fieldType of stringTypes) {
|
||||
expect(
|
||||
getJSType({
|
||||
@@ -49,6 +52,7 @@ test('Returns string for string fields', () => {
|
||||
|
||||
test('Returns boolean for boolean fields', () => {
|
||||
const booleanTypes = ['boolean'];
|
||||
|
||||
for (const fieldType of booleanTypes) {
|
||||
expect(
|
||||
getJSType({
|
||||
@@ -63,6 +67,7 @@ test('Returns boolean for boolean fields', () => {
|
||||
|
||||
test('Returns string for datetime fields', () => {
|
||||
const dateTypes = ['time', 'timestamp', 'date', 'dateTime'];
|
||||
|
||||
for (const fieldType of dateTypes) {
|
||||
expect(
|
||||
getJSType({
|
||||
@@ -77,6 +82,7 @@ test('Returns string for datetime fields', () => {
|
||||
|
||||
test('Returns object for json and csv fields', () => {
|
||||
const objectTypes = ['json', 'csv'];
|
||||
|
||||
for (const fieldType of objectTypes) {
|
||||
expect(
|
||||
getJSType({
|
||||
@@ -91,6 +97,7 @@ test('Returns object for json and csv fields', () => {
|
||||
|
||||
test('Returns object for geometry fields', () => {
|
||||
const geometryTypes = ['geometryPoint', 'geometryPolygon', 'geometryLineString'];
|
||||
|
||||
for (const fieldType of geometryTypes) {
|
||||
expect(
|
||||
getJSType({
|
||||
@@ -105,6 +112,7 @@ test('Returns object for geometry fields', () => {
|
||||
|
||||
test('Returns undefined as fallback', () => {
|
||||
const errorTypes = ['non-existent', 'should also error', '🦄'];
|
||||
|
||||
for (const fieldType of errorTypes) {
|
||||
expect(
|
||||
getJSType({
|
||||
|
||||
@@ -7,6 +7,7 @@ const nonPrefixedSpecials = ['uuid', 'hash', 'geometry'];
|
||||
|
||||
test('Returns cast-prefixed special array for json, csv, and boolean field types', () => {
|
||||
const types = TYPES.filter((type) => castPrefixedSpecials.includes(type));
|
||||
|
||||
for (const type of types) {
|
||||
expect(getSpecialForType(type)).toStrictEqual(['cast-' + type]);
|
||||
}
|
||||
@@ -14,6 +15,7 @@ test('Returns cast-prefixed special array for json, csv, and boolean field types
|
||||
|
||||
test('Returns special array for uuid, hash, and geometry field types', () => {
|
||||
const types = TYPES.filter((type) => nonPrefixedSpecials.includes(type));
|
||||
|
||||
for (const type of types) {
|
||||
expect(getSpecialForType(type)).toStrictEqual([type]);
|
||||
}
|
||||
@@ -22,6 +24,7 @@ test('Returns special array for uuid, hash, and geometry field types', () => {
|
||||
test('Returns null for other field types', () => {
|
||||
const specials = [...castPrefixedSpecials, ...nonPrefixedSpecials];
|
||||
const types = TYPES.filter((type) => !specials.includes(type));
|
||||
|
||||
for (const type of types) {
|
||||
expect(getSpecialForType(type)).toStrictEqual(null);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export function getVueComponentName(vm: ComponentPublicInstance | null): string
|
||||
const options = typeof vm === 'function' && (vm as any).cid != null ? (vm as any)?.options : vm?.$options;
|
||||
let name = options.name || options.__name || options._componentTag;
|
||||
const file = options.__file;
|
||||
|
||||
if (!name && file) {
|
||||
const match = file.match(/([^/\\]+)\.vue$/);
|
||||
name = match && match[1];
|
||||
|
||||
Reference in New Issue
Block a user