From bc52d30e4120fce99823c29325b642f2275a300e Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Wed, 11 Sep 2019 16:04:06 +0200
Subject: [PATCH] bugfix: screenshot of allen mouse and waxholm bugfix:
 publications on separate lines bugfix: doi parsed incorrectly feat: added
 tests for doiParser pipe

---
 ...useCommonCoordinateFrameworkv32015-100.png} | Bin
 ...useCommonCoordinateFrameworkv32015-200.png} | Bin
 ...useCommonCoordinateFrameworkv32015-300.png} | Bin
 ...useCommonCoordinateFrameworkv32015-400.png} | Bin
 ...enMouseCommonCoordinateFrameworkv32015.png} | Bin
 ....png => WaxholmSpaceratbrainMRIDTI-100.png} | Bin
 ....png => WaxholmSpaceratbrainMRIDTI-200.png} | Bin
 ....png => WaxholmSpaceratbrainMRIDTI-300.png} | Bin
 ....png => WaxholmSpaceratbrainMRIDTI-400.png} | Bin
 ...sv20.png => WaxholmSpaceratbrainMRIDTI.png} | Bin
 .../singleDataset/singleDataset.template.html  |   7 +++++--
 src/util/pipes/doiPipe.pipe.spec.ts            |  17 +++++++++++++++++
 src/util/pipes/doiPipe.pipe.ts                 |   4 ++--
 13 files changed, 24 insertions(+), 4 deletions(-)
 rename src/res/images/{AllenadultmousebrainreferenceatlasV3BrainAtlas-100.png => AllenMouseCommonCoordinateFrameworkv32015-100.png} (100%)
 rename src/res/images/{AllenadultmousebrainreferenceatlasV3BrainAtlas-200.png => AllenMouseCommonCoordinateFrameworkv32015-200.png} (100%)
 rename src/res/images/{AllenadultmousebrainreferenceatlasV3BrainAtlas-300.png => AllenMouseCommonCoordinateFrameworkv32015-300.png} (100%)
 rename src/res/images/{AllenadultmousebrainreferenceatlasV3BrainAtlas-400.png => AllenMouseCommonCoordinateFrameworkv32015-400.png} (100%)
 rename src/res/images/{AllenadultmousebrainreferenceatlasV3BrainAtlas.png => AllenMouseCommonCoordinateFrameworkv32015.png} (100%)
 rename src/res/images/{WaxholmSpaceratbrainatlasv20-100.png => WaxholmSpaceratbrainMRIDTI-100.png} (100%)
 rename src/res/images/{WaxholmSpaceratbrainatlasv20-200.png => WaxholmSpaceratbrainMRIDTI-200.png} (100%)
 rename src/res/images/{WaxholmSpaceratbrainatlasv20-300.png => WaxholmSpaceratbrainMRIDTI-300.png} (100%)
 rename src/res/images/{WaxholmSpaceratbrainatlasv20-400.png => WaxholmSpaceratbrainMRIDTI-400.png} (100%)
 rename src/res/images/{WaxholmSpaceratbrainatlasv20.png => WaxholmSpaceratbrainMRIDTI.png} (100%)
 create mode 100644 src/util/pipes/doiPipe.pipe.spec.ts

diff --git a/src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas-100.png b/src/res/images/AllenMouseCommonCoordinateFrameworkv32015-100.png
similarity index 100%
rename from src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas-100.png
rename to src/res/images/AllenMouseCommonCoordinateFrameworkv32015-100.png
diff --git a/src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas-200.png b/src/res/images/AllenMouseCommonCoordinateFrameworkv32015-200.png
similarity index 100%
rename from src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas-200.png
rename to src/res/images/AllenMouseCommonCoordinateFrameworkv32015-200.png
diff --git a/src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas-300.png b/src/res/images/AllenMouseCommonCoordinateFrameworkv32015-300.png
similarity index 100%
rename from src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas-300.png
rename to src/res/images/AllenMouseCommonCoordinateFrameworkv32015-300.png
diff --git a/src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas-400.png b/src/res/images/AllenMouseCommonCoordinateFrameworkv32015-400.png
similarity index 100%
rename from src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas-400.png
rename to src/res/images/AllenMouseCommonCoordinateFrameworkv32015-400.png
diff --git a/src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas.png b/src/res/images/AllenMouseCommonCoordinateFrameworkv32015.png
similarity index 100%
rename from src/res/images/AllenadultmousebrainreferenceatlasV3BrainAtlas.png
rename to src/res/images/AllenMouseCommonCoordinateFrameworkv32015.png
diff --git a/src/res/images/WaxholmSpaceratbrainatlasv20-100.png b/src/res/images/WaxholmSpaceratbrainMRIDTI-100.png
similarity index 100%
rename from src/res/images/WaxholmSpaceratbrainatlasv20-100.png
rename to src/res/images/WaxholmSpaceratbrainMRIDTI-100.png
diff --git a/src/res/images/WaxholmSpaceratbrainatlasv20-200.png b/src/res/images/WaxholmSpaceratbrainMRIDTI-200.png
similarity index 100%
rename from src/res/images/WaxholmSpaceratbrainatlasv20-200.png
rename to src/res/images/WaxholmSpaceratbrainMRIDTI-200.png
diff --git a/src/res/images/WaxholmSpaceratbrainatlasv20-300.png b/src/res/images/WaxholmSpaceratbrainMRIDTI-300.png
similarity index 100%
rename from src/res/images/WaxholmSpaceratbrainatlasv20-300.png
rename to src/res/images/WaxholmSpaceratbrainMRIDTI-300.png
diff --git a/src/res/images/WaxholmSpaceratbrainatlasv20-400.png b/src/res/images/WaxholmSpaceratbrainMRIDTI-400.png
similarity index 100%
rename from src/res/images/WaxholmSpaceratbrainatlasv20-400.png
rename to src/res/images/WaxholmSpaceratbrainMRIDTI-400.png
diff --git a/src/res/images/WaxholmSpaceratbrainatlasv20.png b/src/res/images/WaxholmSpaceratbrainMRIDTI.png
similarity index 100%
rename from src/res/images/WaxholmSpaceratbrainatlasv20.png
rename to src/res/images/WaxholmSpaceratbrainMRIDTI.png
diff --git a/src/ui/databrowserModule/singleDataset/singleDataset.template.html b/src/ui/databrowserModule/singleDataset/singleDataset.template.html
index adeb851f8..2abde63a3 100644
--- a/src/ui/databrowserModule/singleDataset/singleDataset.template.html
+++ b/src/ui/databrowserModule/singleDataset/singleDataset.template.html
@@ -14,12 +14,15 @@
 
   <!-- publications -->
   <mat-card-content>
-    <div class="d-inline-block mb-2"
+    <div class="d-block mb-2"
       *ngFor="let publication of publications">
-      <a [href]="publication.doi | doiParserPipe"
+      <a *ngIf="publication.doi; else plainText" [href]="publication.doi | doiParserPipe"
         target="_blank">
         {{ publication.cite }}
       </a>
+      <ng-template #plainText>
+        {{ publication.cite }}
+      </ng-template>
     </div>
   </mat-card-content>
 
diff --git a/src/util/pipes/doiPipe.pipe.spec.ts b/src/util/pipes/doiPipe.pipe.spec.ts
new file mode 100644
index 000000000..300f84ffc
--- /dev/null
+++ b/src/util/pipes/doiPipe.pipe.spec.ts
@@ -0,0 +1,17 @@
+import {} from 'jasmine'
+import { DoiParserPipe } from './doiPipe.pipe'
+
+describe('doiPipe.pipe.ts', () => {
+  const pipe = new DoiParserPipe()
+  describe('DoiParsePIpe' , () => {
+    it('should parse string without prefix by appending doi prefix', () => {
+      const result = pipe.transform('123.456')
+      expect(result).toBe(`https://doi.org/123.456`)
+    })
+
+    it('should not append doi prefix if the first argument leads by http or https', () => {
+      expect(pipe.transform('http://google.com')).toBe('http://google.com')
+      expect(pipe.transform('https://google.com')).toBe('https://google.com')
+    })
+  })
+})
\ No newline at end of file
diff --git a/src/util/pipes/doiPipe.pipe.ts b/src/util/pipes/doiPipe.pipe.ts
index 353b8ea65..913401ec1 100644
--- a/src/util/pipes/doiPipe.pipe.ts
+++ b/src/util/pipes/doiPipe.pipe.ts
@@ -6,7 +6,7 @@ import { Pipe, PipeTransform } from "@angular/core";
 
 export class DoiParserPipe implements PipeTransform{
   public transform(s: string, prefix: string = 'https://doi.org/'){
-    const prependFlag = /^https?:\.\./.test(s)
-    return `${prependFlag ? prefix : ''}${s}`
+    const hasProtocol = /^https?\:\/\//.test(s)
+    return `${hasProtocol ? '' : prefix}${s}`
   }
 }
\ No newline at end of file
-- 
GitLab