Revert "Fix: respect baseURI for pdfjs worker URL"

This reverts commit b91c7db3e004cf981f0b2782d4bab1bf82bab742.
This commit is contained in:
shamoon 2023-12-06 14:35:07 -08:00
parent a4d6cab03b
commit 594226d5a4
5 changed files with 11 additions and 11 deletions

View File

@ -33,7 +33,6 @@ import type {
ZoomScale, ZoomScale,
} from './typings' } from './typings'
import { PDFSinglePageViewer } from 'pdfjs-dist/web/pdf_viewer' import { PDFSinglePageViewer } from 'pdfjs-dist/web/pdf_viewer'
import { environment } from 'src/environments/environment'
PDFJS['verbosity'] = PDFJS.VerbosityLevel.ERRORS PDFJS['verbosity'] = PDFJS.VerbosityLevel.ERRORS
@ -232,8 +231,7 @@ export class PdfViewerComponent
private element: ElementRef<HTMLElement>, private element: ElementRef<HTMLElement>,
private ngZone: NgZone private ngZone: NgZone
) { ) {
PDFJS.GlobalWorkerOptions['workerSrc'] = PDFJS.GlobalWorkerOptions['workerSrc'] = '/assets/js/pdf.worker.min.js'
`${environment.baseUrl}assets/js/pdf.worker.min.js`
} }
ngAfterViewChecked(): void { ngAfterViewChecked(): void {

View File

@ -194,19 +194,20 @@ describe('ShareLinksDropdownComponent', () => {
}) })
it('should correctly generate share URLs', () => { it('should correctly generate share URLs', () => {
environment.baseUrl = 'http://example.com/' environment.apiBaseUrl = 'http://example.com/api/'
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual( expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
'http://example.com/share/123abc123' 'http://example.com/share/123abc123'
) )
environment.baseUrl = 'http://example.domainwithapiinit.com/' environment.apiBaseUrl = 'http://example.domainwithapiinit.com/api/'
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual( expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
'http://example.domainwithapiinit.com/share/123abc123' 'http://example.domainwithapiinit.com/share/123abc123'
) )
environment.baseUrl = 'http://example.domainwithapiinit.com:1234/' environment.apiBaseUrl = 'http://example.domainwithapiinit.com:1234/api/'
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual( expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
'http://example.domainwithapiinit.com:1234/share/123abc123' 'http://example.domainwithapiinit.com:1234/share/123abc123'
) )
environment.baseUrl = 'http://example.domainwithapiinit.com:1234/subpath/' environment.apiBaseUrl =
'http://example.domainwithapiinit.com:1234/subpath/api/'
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual( expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
'http://example.domainwithapiinit.com:1234/subpath/share/123abc123' 'http://example.domainwithapiinit.com:1234/subpath/share/123abc123'
) )

View File

@ -80,7 +80,10 @@ export class ShareLinksDropdownComponent implements OnInit {
} }
getShareUrl(link: PaperlessShareLink): string { getShareUrl(link: PaperlessShareLink): string {
return `${environment.baseUrl}share/${link.slug}` const apiURL = new URL(environment.apiBaseUrl)
return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${
link.slug
}`
} }
getDaysRemaining(link: PaperlessShareLink): string { getDaysRemaining(link: PaperlessShareLink): string {

View File

@ -2,8 +2,7 @@ const base_url = new URL(document.baseURI)
export const environment = { export const environment = {
production: true, production: true,
baseUrl: base_url, apiBaseUrl: document.baseURI + 'api/',
apiBaseUrl: `${base_url}api/`,
apiVersion: '3', apiVersion: '3',
appTitle: 'Paperless-ngx', appTitle: 'Paperless-ngx',
version: '2.1.0-dev', version: '2.1.0-dev',

View File

@ -4,7 +4,6 @@
export const environment = { export const environment = {
production: false, production: false,
baseUrl: 'http://localhost:8000/',
apiBaseUrl: 'http://localhost:8000/api/', apiBaseUrl: 'http://localhost:8000/api/',
apiVersion: '3', apiVersion: '3',
appTitle: 'Paperless-ngx', appTitle: 'Paperless-ngx',