Fix: respect baseURI for pdfjs worker URL
This commit is contained in:
parent
aa858a35e2
commit
a4d6cab03b
@ -33,6 +33,7 @@ import type {
|
||||
ZoomScale,
|
||||
} from './typings'
|
||||
import { PDFSinglePageViewer } from 'pdfjs-dist/web/pdf_viewer'
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
PDFJS['verbosity'] = PDFJS.VerbosityLevel.ERRORS
|
||||
|
||||
@ -231,7 +232,8 @@ export class PdfViewerComponent
|
||||
private element: ElementRef<HTMLElement>,
|
||||
private ngZone: NgZone
|
||||
) {
|
||||
PDFJS.GlobalWorkerOptions['workerSrc'] = '/assets/js/pdf.worker.min.js'
|
||||
PDFJS.GlobalWorkerOptions['workerSrc'] =
|
||||
`${environment.baseUrl}assets/js/pdf.worker.min.js`
|
||||
}
|
||||
|
||||
ngAfterViewChecked(): void {
|
||||
|
@ -194,20 +194,19 @@ describe('ShareLinksDropdownComponent', () => {
|
||||
})
|
||||
|
||||
it('should correctly generate share URLs', () => {
|
||||
environment.apiBaseUrl = 'http://example.com/api/'
|
||||
environment.baseUrl = 'http://example.com/'
|
||||
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
|
||||
'http://example.com/share/123abc123'
|
||||
)
|
||||
environment.apiBaseUrl = 'http://example.domainwithapiinit.com/api/'
|
||||
environment.baseUrl = 'http://example.domainwithapiinit.com/'
|
||||
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
|
||||
'http://example.domainwithapiinit.com/share/123abc123'
|
||||
)
|
||||
environment.apiBaseUrl = 'http://example.domainwithapiinit.com:1234/api/'
|
||||
environment.baseUrl = 'http://example.domainwithapiinit.com:1234/'
|
||||
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
|
||||
'http://example.domainwithapiinit.com:1234/share/123abc123'
|
||||
)
|
||||
environment.apiBaseUrl =
|
||||
'http://example.domainwithapiinit.com:1234/subpath/api/'
|
||||
environment.baseUrl = 'http://example.domainwithapiinit.com:1234/subpath/'
|
||||
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
|
||||
'http://example.domainwithapiinit.com:1234/subpath/share/123abc123'
|
||||
)
|
||||
|
@ -80,10 +80,7 @@ export class ShareLinksDropdownComponent implements OnInit {
|
||||
}
|
||||
|
||||
getShareUrl(link: PaperlessShareLink): string {
|
||||
const apiURL = new URL(environment.apiBaseUrl)
|
||||
return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${
|
||||
link.slug
|
||||
}`
|
||||
return `${environment.baseUrl}share/${link.slug}`
|
||||
}
|
||||
|
||||
getDaysRemaining(link: PaperlessShareLink): string {
|
||||
|
@ -2,7 +2,8 @@ const base_url = new URL(document.baseURI)
|
||||
|
||||
export const environment = {
|
||||
production: true,
|
||||
apiBaseUrl: document.baseURI + 'api/',
|
||||
baseUrl: base_url,
|
||||
apiBaseUrl: `${base_url}api/`,
|
||||
apiVersion: '3',
|
||||
appTitle: 'Paperless-ngx',
|
||||
version: '2.1.0-dev',
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
baseUrl: 'http://localhost:8000/',
|
||||
apiBaseUrl: 'http://localhost:8000/api/',
|
||||
apiVersion: '3',
|
||||
appTitle: 'Paperless-ngx',
|
||||
|
Loading…
x
Reference in New Issue
Block a user