Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@hettiger/ngx-fragment-link-faker
Advanced tools
Mimics default browser behavior of fragment links in Angular applications.
Mimics default browser behavior of fragment links in Angular applications.
Allows applying changes in a scoped manner using a simple directive.
Supports smooth scroll behavior.
This library was generated with Angular CLI version 13.0.0.
E.g. you have existing HTML content with a table of contents:
<h2>Table of contents</h2>
<ul>
<li>
<a href="#some-headline">Some Headline</a>
<a href="#another-headline">Another Headline</a>
</li>
</ul>
<article>
<h2 id="some-headline">Some Headline</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</p>
</article>
<article>
<h2>
<a name="another-headline"></a>
Some Headline
</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</p>
</article>
This table of contents does not work as expected in an Angular app.
Clicking one of the links would not adjust the scroll position.
Instead you'd trigger a navigation to the homepage.
Usually the solution requires manual changes to the original HTML content.
Also you'd typically need to handle click events or fragment changes somehow.
Probably you want a nice smooth scroll effect that works in all major browser.
This library gets the job done without changing any of the existing HTML contents.
ng add @hettiger/ngx-fragment-link-faker
Simply add the mhFakeFragmentLinks
directive to a wrapper element in your template.
In case you need to account for e.g. a fixed navbar simply provide a delta in px.
Example: <main mhFakeFragmentLinks [mhScrollTopDelta]="64"> … </main>
You might as well configure the scroll behavior to enable smooth scrolling:
Example: <main mhFakeFragmentLinks mhScrollBehavior="smooth"> … </main>
Smooth scroll behavior is not supported in all browsers at the time of writing.
However, you may simply add a polyfill for now:
npm i seamless-scroll-polyfill --save
// src/polyfills.ts import { polyfill as polyfillSeamlessScroll } from "seamless-scroll-polyfill"; polyfillSeamlessScroll();
<main mhFakeFragmentLinks [mhScrollTopDelta]="20" mhScrollBehavior="smooth">
<h2>Table of contents</h2>
<ul>
<li>
<a href="#some-headline">Some Headline</a>
<a href="#another-headline">Another Headline</a>
</li>
</ul>
<!-- … -->
</main>
Run ng generate component component-name --project ngx-fragment-link-faker
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module --project ngx-fragment-link-faker
.
Note: Don't forget to add
--project ngx-fragment-link-faker
or else it will be added to the default project in yourangular.json
file.
Run ng build ngx-fragment-link-faker
to build the project. The build artifacts will be stored in the dist/
directory.
After building your library with ng build ngx-fragment-link-faker
, go to the dist folder cd dist/ngx-fragment-link-faker
and run npm publish
.
Run ng test ngx-fragment-link-faker
to execute the unit tests via Karma.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI Overview and Command Reference page.
The NgxFragmentLinkFaker library is open-sourced software licensed under the MIT license.
FAQs
Mimics default browser behavior of fragment links in Angular applications.
The npm package @hettiger/ngx-fragment-link-faker receives a total of 0 weekly downloads. As such, @hettiger/ngx-fragment-link-faker popularity was classified as not popular.
We found that @hettiger/ngx-fragment-link-faker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.