diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2e68544..ef02e953 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: jobs: lint: continue-on-error: true - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 @@ -21,7 +21,7 @@ jobs: - run: npm run lint unit-tests: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 @@ -38,7 +38,7 @@ jobs: mutation-tests: continue-on-error: true - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 @@ -52,7 +52,7 @@ jobs: - run: npm run mutate -- --mutate=$(git diff origin/main --name-only | grep -E 'src\/(.*).(ts|tsx)$' | paste -sd ",") build-docker-image: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/docker-image-build.yml b/.github/workflows/docker-image-build.yml index 50a0d4ba..36ff3809 100644 --- a/.github/workflows/docker-image-build.yml +++ b/.github/workflows/docker-image-build.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 5f857f89..fac8fded 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b931691..da1228f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org). -## [Unreleased] +## [3.0.1] - 2020-12-30 ### Added * *Nothing* @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * [#366](https://github.com/shlinkio/shlink-web-client/issues/366) Fixed text in visits menu jumping to next line in some tablet resolutions. * [#367](https://github.com/shlinkio/shlink-web-client/issues/367) Removed conflicting overflow in visits table for mobile devices. * [#365](https://github.com/shlinkio/shlink-web-client/issues/365) Fixed weird rendering of short URLs list in tablets. +* [#372](https://github.com/shlinkio/shlink-web-client/issues/372) Fixed importing servers in Android devices. ## [3.0.0] - 2020-12-22 diff --git a/package.json b/package.json index 7606cd82..223ed929 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "repository": "https://github.com/shlinkio/shlink-web-client", "license": "MIT", "scripts": { - "lint": "npm run lint:js && npm run lint:css", + "lint": "npm run lint:css && npm run lint:js", "lint:js": "eslint --ext .js,.ts,.tsx src test scripts config", "lint:js:fix": "npm run lint:js -- --fix", "lint:css": "stylelint src/*.scss src/**/*.scss", diff --git a/src/servers/services/ServersImporter.ts b/src/servers/services/ServersImporter.ts index 62de8f53..03c1ca25 100644 --- a/src/servers/services/ServersImporter.ts +++ b/src/servers/services/ServersImporter.ts @@ -1,13 +1,19 @@ import { CsvJson } from 'csvjson'; import { ServerData } from '../data'; -const CSV_MIME_TYPE = 'text/csv'; + +interface CsvFile extends File { + type: 'text/csv' | 'text/comma-separated-values' | 'application/csv'; +} + +const CSV_MIME_TYPES = [ 'text/csv', 'text/comma-separated-values', 'application/csv' ]; +const isCsv = (file?: File | null): file is CsvFile => !!file && CSV_MIME_TYPES.includes(file.type); export default class ServersImporter { public constructor(private readonly csvjson: CsvJson, private readonly fileReaderFactory: () => FileReader) {} public readonly importServersFromFile = async (file?: File | null): Promise => { - if (!file || file.type !== CSV_MIME_TYPE) { + if (!isCsv(file)) { throw new Error('No file provided or file is not a CSV'); } diff --git a/test/servers/services/ServersImporter.test.ts b/test/servers/services/ServersImporter.test.ts index 28c4e390..f6749ca6 100644 --- a/test/servers/services/ServersImporter.test.ts +++ b/test/servers/services/ServersImporter.test.ts @@ -29,8 +29,12 @@ describe('ServersImporter', () => { ); }); - it('reads file when a CSV is provided', async () => { - await importer.importServersFromFile(Mock.of({ type: 'text/csv' })); + it.each([ + [ 'text/csv' ], + [ 'text/comma-separated-values' ], + [ 'application/csv' ], + ])('reads file when a CSV is provided', async (type) => { + await importer.importServersFromFile(Mock.of({ type })); expect(readAsText).toHaveBeenCalledTimes(1); expect(toObject).toHaveBeenCalledTimes(1);