Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

fix: external links with hash are updated incorrectly #355

Merged
merged 1 commit into from
Dec 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/app/shared/doc-viewer/doc-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,10 @@ export class DocViewer implements OnDestroy {
const anchorElements =
[].slice.call(this._elementRef.nativeElement.querySelectorAll('a')) as HTMLAnchorElement[];

// Update hash links that are referring to the same page and host. Links that are referring
// to a different destination shouldn't be updated. For example the Google Fonts URL.
anchorElements
.filter(anchorEl => anchorEl.hash)
.filter(anchorEl => anchorEl.hash && anchorEl.host === location.host)
.forEach(anchorEl => anchorEl.href = `${baseUrl}${anchorEl.hash}`);
}

Expand Down